Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
laurigates committed Sep 18, 2023
1 parent 185ae19 commit 03334db
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Use the BusyBox base image
FROM busybox
FROM python:3.11-alpine

# Create a directory for serving the HTML file
RUN mkdir -p /www
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Copy the index.html file to the /www directory in the container
COPY index.html /www/index.html
RUN addgroup -S app && adduser -S app -G app
WORKDIR /home/app

# Create an unprivileged user
RUN adduser -D -H -s /bin/sh httpuser
# Copy and install requirements only first to cache the dependency layer
COPY --chown=app:app requirements.txt .
RUN pip install --no-cache-dir --no-compile --upgrade -r requirements.txt

# Change ownership of the /www directory to the unprivileged user
RUN chown -R httpuser /www
COPY --chown=app:app . .

# Expose port 8080 for the HTTP server to listen on
EXPOSE 8080
# Support Arbitrary User IDs
RUN chgrp -R 0 /home/app && \
chmod -R g+rwX /home/app

# Switch to the unprivileged user and start the BusyBox HTTP server
USER httpuser
CMD httpd -f -p 8080 -h /www
USER app

CMD ["/home/app/.local/bin/uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers"]
EXPOSE 8000/tcp

0 comments on commit 03334db

Please sign in to comment.