-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
60 additions
and
25 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,51 @@ | ||
FROM python:3.6.2-alpine3.6 | ||
ENV PYTHONBUFFERED 1 | ||
FROM python:alpine3.7 | ||
ARG DJANGO_SETTINGS_MODULE | ||
ARG DJANGO_ADMIN_URL | ||
ARG DJANGO_SECRET_KEY | ||
ARG DATABASE_URL | ||
ARG DJANGO_SENTRY_DSN | ||
ENV PYTHONBUFFERED=1 DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE} DJANGO_ADMIN_URL=${DJANGO_ADMIN_URL} DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY} DATABASE_URL=${DATABASE_URL} DJANGO_SENTRY_DSN=${DJANGO_SENTRY_DSN} | ||
|
||
# Add new user to run the whole thing as non-root | ||
RUN addgroup -S app | ||
RUN adduser -G app -h /app -D app | ||
RUN addgroup -S app \ | ||
&& adduser -G app -h /app -D app | ||
|
||
# Copy Pipfile and install system-wide | ||
# We're installing system-wide, because we currently have problems | ||
# correctly using the entrypoint.sh, while activating the virtual environment | ||
COPY Pipfile Pipfile.lock /app/ | ||
WORKDIR /app | ||
|
||
# Install build dependencies for PostgreSQL. While we're at it, also install | ||
# pipenv and all python requirements. Then remove unneeded build dependencies. | ||
RUN apk update \ | ||
# Install build dependencies | ||
RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ | ||
&& apk update \ | ||
&& apk add bash \ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
&& apk add \ | ||
&& apk add --no-cache \ | ||
gcc \ | ||
musl-dev \ | ||
&& apk add --no-cache postgresql postgresql-dev \ | ||
&& pip install pipenv \ | ||
&& pipenv install --system --verbose \ | ||
&& apk del .build-deps | ||
zlib-dev \ | ||
jpeg-dev \ | ||
libxslt-dev \ | ||
libxml2-dev \ | ||
postgresql \ | ||
postgresql-dev \ | ||
jpeg \ | ||
gettext \ | ||
tzdata | ||
|
||
# Set the correct timezone | ||
RUN cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime \ | ||
&& echo "Europe/Berlin" > /etc/timezone | ||
|
||
# Copy Pipfile and install python dependencies | ||
COPY --chown=app:app Pipfile Pipfile.lock / | ||
RUN pip install pipenv | ||
RUN LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pipenv install --system --deploy" | ||
|
||
# Copy dokku specific files to the project root | ||
COPY --chown=app:app docker/dokku/* /app/ | ||
COPY --chown=app:app docker/dokku/entrypoint.sh / | ||
RUN chmod +x entrypoint.sh /app/deploy.sh | ||
|
||
# Change to user and copy code | ||
USER app | ||
COPY . /app | ||
WORKDIR /app | ||
|
||
# Copy dokku specific files | ||
COPY docker/dokku/* /app/ | ||
# Copy all related app files | ||
COPY --chown=app:app . /app | ||
|
||
# Let Django collect all staticfiles | ||
RUN python /app/manage.py collectstatic --noinput | ||
ENTRYPOINT ["/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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"scripts": { | ||
"dokku": { | ||
"predeploy": "python /app/manage.py migrate --noinput" | ||
"predeploy": "sh /app/deploy.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,7 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
python /app/manage.py migrate --noinput | ||
python /app/manage.py compilemessages | ||
yarn prod | ||
python /app/manage.py collectstatic --noinput |
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,11 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# while ! pg_isready -h $POSTGRES_HOST -p $POSTGRES_PORT; do | ||
# >&2 echo "Postgres is unavailable - sleeping" | ||
# sleep 1 | ||
# done | ||
|
||
# >&2 echo "Postgres is up - continuing" | ||
|
||
exec "$@" |