Skip to content

Commit

Permalink
Add missing dokku deploy files
Browse files Browse the repository at this point in the history
  • Loading branch information
mimischi committed Dec 30, 2017
1 parent a6cae48 commit 98bebb4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 25 deletions.
65 changes: 41 additions & 24 deletions docker/dokku/Dockerfile
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"]
2 changes: 1 addition & 1 deletion docker/dokku/app.json
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"
}
}
}
7 changes: 7 additions & 0 deletions docker/dokku/deploy.sh
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
11 changes: 11 additions & 0 deletions docker/dokku/entrypoint.sh
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 "$@"

0 comments on commit 98bebb4

Please sign in to comment.