-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
185ae19
commit 03334db
Showing
1 changed file
with
16 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |