-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Showing
2 changed files
with
70 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
FROM python:3.12.3-slim-bookwor | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Install system dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Create app user | ||
RUN groupadd app \ | ||
&& useradd -g app -d /home/app -s /sbin/nologin app \ | ||
&& mkdir -p /home/app \ | ||
&& chown -R app:app /home/app | ||
|
||
# Create app directory | ||
RUN mkdir /app \ | ||
&& chown -R app:app /app | ||
|
||
# Install system dependencies | ||
RUN pip install --no-cache poetry==1.8.2 | ||
|
||
# Add app directory to Python path | ||
ENV PYTHONPATH=/app | ||
|
||
# Activate app user and change working directory | ||
USER app | ||
WORKDIR /app | ||
|
||
# Install app dependencies | ||
COPY --chown=app ./pyproject.toml ./poetry.toml ./poetry.lock /app/ | ||
RUN poetry install \ | ||
--no-root --no-dev --no-interaction --no-ansi \ | ||
--extras api \ | ||
--extras cache \ | ||
--extras pgsql \ | ||
--extras server | ||
|
||
# Install app | ||
COPY --chown=app ./docker-entrypoint.sh /app/ | ||
COPY --chown=app ./manage.py /app/ | ||
COPY --chown=app ./comics/ /app/comics/ | ||
|
||
# Collect static files | ||
RUN DJANGO_SECRET_KEY=s3cret poetry run python manage.py collectstatic --noinput | ||
|
||
# Entrypoint | ||
ENTRYPOINT ["./docker-entrypoint.sh"] |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Simplified entrypoints for the different services packaged in this | ||
# Docker image. | ||
|
||
if [ "$1" = "shell" ]; then | ||
poetry run pip install ipython | ||
exec poetry run python manage.py shell ${*:2} | ||
fi | ||
|
||
if [ "$1" = "migrate" ]; then | ||
exec poetry run python manage.py migrate ${*:2} | ||
fi | ||
|
||
if [ "$1" = "web" ]; then | ||
exec poetry run gunicorn --worker-tmp-dir=/dev/shm --log-file=- --bind=0.0.0.0:$PORT comics.wsgi ${*:2} | ||
fi | ||
|
||
exec "$@" |