-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using the pre-built wheels from PyPI with the Debian-based images is a lot more efficient: 1.2G vs. 0.2G.
- Loading branch information
1 parent
b2c2643
commit 0fdf4d4
Showing
2 changed files
with
9 additions
and
16 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,34 +1,25 @@ | ||
FROM python:3.10-alpine | ||
FROM python:3.10-slim | ||
|
||
MAINTAINER "TheAssassin <[email protected]>" | ||
|
||
# this port won't ever change, really | ||
EXPOSE 5000 | ||
|
||
# install dependencies | ||
RUN apk add --no-cache gcc libxml2-dev libxml2 musl-dev xmlsec xmlsec-dev curl libffi-dev openssl-dev make rust cargo | ||
|
||
# create non-root user | ||
RUN adduser -S app | ||
|
||
# install poetry system-wide, the rest per user | ||
# for some reason, we can't just pip install the entire package, but have to invoke poetry directly... | ||
RUN pip install poetry | ||
RUN adduser app | ||
|
||
USER app | ||
WORKDIR /app | ||
|
||
# must provide both the | ||
COPY pyproject.toml poetry.lock /app/ | ||
COPY README.md pyproject.toml poetry.lock /app/ | ||
COPY np_web_api/ /app/np_web_api/ | ||
|
||
# note: pip doesn't support editable (-e) installs with pyproject.toml only | ||
RUN poetry install | ||
RUN pip install . | ||
|
||
HEALTHCHECK --interval=5m --timeout=15s \ | ||
CMD curl -f http://localhost:5000/data.json || exit 1 | ||
|
||
COPY np_web_api/ /app/np_web_api/ | ||
|
||
# using just one worker worked fine so far, and allows for some very crappy "synchronization" between requests by just | ||
# using global variables, which help prevent concurrent requests to update cached data | ||
CMD ["poetry", "run", "uvicorn", "np_web_api.asgi:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "1", "--no-access-log"] | ||
CMD ["python", "-m", "uvicorn", "np_web_api.asgi:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "1", "--no-access-log"] |
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