-
-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run as alpine docker image and server static files with gunicorn
- Loading branch information
Showing
6 changed files
with
43 additions
and
23 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
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,24 +1,23 @@ | ||
FROM python:3.8-slim-buster | ||
FROM python:3.8-alpine | ||
|
||
RUN mkdir /Recipes | ||
WORKDIR /Recipes | ||
|
||
ADD . /Recipes/ | ||
|
||
RUN apt-get update | ||
RUN apt-get -y upgrade | ||
RUN apt-get install -y \ | ||
python3 \ | ||
python3-pip \ | ||
postgresql-client \ | ||
gettext | ||
|
||
RUN pip3 install --upgrade pip | ||
RUN apk add --no-cache postgresql-libs gettext zlib libjpeg libxml2-dev libxslt-dev | ||
ENV PYTHONUNBUFFERED 1 | ||
EXPOSE 8080 | ||
|
||
RUN pip3 install -r requirements.txt | ||
# Don't run container as root | ||
RUN adduser -D recipes | ||
|
||
RUN apt-get autoremove -y | ||
RUN mkdir /opt/recipes | ||
RUN chown recipes:recipes /opt/recipes | ||
WORKDIR /opt/recipes | ||
COPY --chown=recipes:recipes . ./ | ||
RUN pwd && ls -lha | ||
RUN chmod +x boot.sh | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev && \ | ||
python -m venv venv && \ | ||
venv/bin/pip install -r requirements.txt --no-cache-dir &&\ | ||
apk --purge del .build-deps | ||
|
||
EXPOSE 8080 | ||
USER recipes | ||
ENTRYPOINT ["/opt/recipes/boot.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,9 @@ | ||
#!/bin/sh | ||
source venv/bin/activate | ||
|
||
echo "Updating database" | ||
python3 manage.py migrate | ||
python3 manage.py collectstatic --noinput | ||
echo "Done" | ||
|
||
exec gunicorn -b :8080 --access-logfile - --error-logfile - recipes.wsgi |
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
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
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 |
---|---|---|
|
@@ -17,4 +17,5 @@ lxml | |
webdavclient3 | ||
python-dotenv | ||
psycopg2-binary | ||
whitenoise | ||
gunicorn |