diff options
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/app/Dockerfile | 46 | ||||
| -rw-r--r-- | docker/app/Dockerfile.local | 49 | ||||
| -rw-r--r-- | docker/app/local.Dockerfile | 26 | ||||
| -rwxr-xr-x | docker/app/scripts/migrate_and_serve.sh | 3 | ||||
| -rw-r--r-- | docker/pysite.dockerapp | 42 | 
5 files changed, 39 insertions, 127 deletions
diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index 903e7dc6..15b1f77b 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -2,49 +2,25 @@ FROM bitnami/python:3.7-prod  # I have no idea what this does.  STOPSIGNAL SIGQUIT -ARG EXTRAS=deploy + +ENV PIP_NO_CACHE_DIR=false \ +    PIPENV_HIDE_EMOJIS=1 \ +    PIPENV_NOSPIN=1  # Create a user. -RUN adduser \ -    --disabled-login \ -    --no-create-home \ -    --uid 1500 \ -    pysite +RUN useradd --system --shell /bin/false --uid 1500 pysite  # Install prerequisites needed to complete the dependency installation. -RUN apt-get update -y \ -    && \ -        apt-get install --no-install-recommends -y \ -                gcc \ -                libc-dev \ -                libpq-dev \ -                git \ -    && \ -        apt-get clean \ -    && \ -        rm -rf /var/lib/apt/lists/* +RUN install_packages git uwsgi -# Set up the working directory. +# Copy the project files into the working directory.  WORKDIR /app -COPY Pipfile Pipfile.lock /app/ - -# Pip install the stuff we'll need. -RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \ -    pip install --no-cache-dir -U setuptools -RUN python3 -m pip install pipenv \ -    && python3 -m pipenv install --system --deploy \ -    && pip install uwsgi==2.0.18 - -# Copy everything into the docker environment.  COPY . . -# RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0 - -# Remove the prerequisites, dependency installation is now complete. -RUN apt-get purge -y \ -            gcc \ -            libc-dev \ -            libpq-dev +# Update setuptools by removing egg first, add other dependencies +RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \ +    pip install --no-cache-dir -U setuptools pipenv +RUN pipenv install --system --deploy  # Migrate, collect and start the app.  RUN chmod +x /app/docker/app/scripts/migrate.sh diff --git a/docker/app/Dockerfile.local b/docker/app/Dockerfile.local deleted file mode 100644 index c332c757..00000000 --- a/docker/app/Dockerfile.local +++ /dev/null @@ -1,49 +0,0 @@ -FROM bitnami/python:3.7-prod - -# I have no idea what this does. -STOPSIGNAL SIGQUIT -ARG EXTRAS=deploy - -# Create a user. -RUN adduser \ -    --disabled-login \ -    --no-create-home \ -    --uid 1500 \ -    pysite - -# Install prerequisites needed to complete the dependency installation. -RUN apt-get update -y \ -    && \ -        apt-get install --no-install-recommends -y \ -                gcc \ -                libc-dev \ -                libpq-dev \ -                git \ -    && \ -        apt-get clean \ -    && \ -        rm -rf /var/lib/apt/lists/* - -# Set up the working directory. -WORKDIR /app -COPY Pipfile Pipfile.lock /app/ - -# Pip install the stuff we'll need. -RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \ -    pip install --no-cache-dir -U setuptools -RUN python3 -m pip install pipenv \ -    && python3 -m pipenv install --system --deploy \ -    && pip install uwsgi==2.0.18 - -# Copy everything into the docker environment. -COPY . . - -RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0 - -# Remove the prerequisites, dependency installation is now complete. -RUN apt-get purge -y \ -            gcc \ -            libc-dev \ -            libpq-dev - -CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"] diff --git a/docker/app/local.Dockerfile b/docker/app/local.Dockerfile new file mode 100644 index 00000000..124dab95 --- /dev/null +++ b/docker/app/local.Dockerfile @@ -0,0 +1,26 @@ +FROM bitnami/python:3.7-prod + +STOPSIGNAL SIGQUIT + +ENV PIP_NO_CACHE_DIR=false \ +    PIPENV_HIDE_EMOJIS=1 \ +    PIPENV_NOSPIN=1 + +# Create a user. +RUN useradd --system --shell /bin/false --uid 1500 pysite + +# Install prerequisites needed to complete the dependency installation. +RUN install_packages git uwsgi + +# Copy the project files into the working directory. +WORKDIR /app +COPY . . + +# Update setuptools by removing egg first, add other dependencies +RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \ +    pip install --no-cache-dir -U setuptools pipenv +RUN pipenv install --system --deploy + +RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0 + +CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"] diff --git a/docker/app/scripts/migrate_and_serve.sh b/docker/app/scripts/migrate_and_serve.sh index 0b54a2e5..c30d7e04 100755 --- a/docker/app/scripts/migrate_and_serve.sh +++ b/docker/app/scripts/migrate_and_serve.sh @@ -1,4 +1,5 @@ -#!/bin/sh -eu +#!/bin/sh +set -eu  ### NOTE  # This file is intended to be used by local setups. diff --git a/docker/pysite.dockerapp b/docker/pysite.dockerapp deleted file mode 100644 index 4e90ff87..00000000 --- a/docker/pysite.dockerapp +++ /dev/null @@ -1,42 +0,0 @@ -version: 0.3.0 -name: pysite -description: | -    Our community website, built on Django and PostgreSQL. -namespace: python-discord -maintainers: -  - name: Johannes Christ -    email: [email protected] - ---- -version: "3.6" -services: -    django: -        build: -            context: . -        command: docker/app/scripts/migrate_and_serve.sh -        ports: -            - "127.0.0.1:4000:4000" -        environment: -            DATABASE_URL: "postgres://${pg_user}:${pg_passwd}@${pg_host}/${pg_db}" -            DEBUG: 'false' -            SECRET_KEY: "${secret_key}" -        depends_on: -            - postgres - -    postgres: -        image: postgres:11-alpine -        ports: -            - "127.0.0.1:5432:5432" -        environment: -            POSTGRES_DB: "${pg_db}" -            POSTGRES_USER: "${pg_user}" -            POSTGRES_PASSWORD: "${pg_passwd}" - ---- -pg_user: pysite -pg_db: pysite -pg_passwd: supersecretpassword -pg_host: postgres -secret_key: 'suitable-for-development-only' - -# vim: ft=yaml:  |