From 1a9215ac4b3b859a8f9b96fdf64ea05ae8cdcdf0 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Wed, 5 Sep 2018 20:07:10 +0200 Subject: Add `nging` for static files. --- .gitlab-ci.yml | 10 +++++++++- docker/nging/Dockerfile | 16 ++++++++++++++++ docker/pysite.dockerapp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ pysite.dockerapp | 49 ------------------------------------------------- 4 files changed, 74 insertions(+), 50 deletions(-) create mode 100644 docker/nging/Dockerfile create mode 100644 docker/pysite.dockerapp delete mode 100644 pysite.dockerapp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fb5363c9..78b6eda9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,11 +108,19 @@ push-django: image: docker:stable-git stage: deploy script: - - docker build -t pythondiscord/django:latest . - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin + - docker build -t pythondiscord/django:latest . - docker push pythondiscord/django:latest only: - master - django tags: - docker + +push-nging: + image: docker:stable-git + stage: deploy + script: + - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin + - docker build -t pythondiscord/nging:latest . + - docker push pythondiscord/nging:latest diff --git a/docker/nging/Dockerfile b/docker/nging/Dockerfile new file mode 100644 index 00000000..4d32af6c --- /dev/null +++ b/docker/nging/Dockerfile @@ -0,0 +1,16 @@ +FROM pythondiscord/django AS builder + +ENV DATABASE_URL postgres://user:pass@host/db +ENV SECRET_KEY unused + +RUN mkdir -p /var/www/pythondiscord.com + +RUN python3 manage.py collectstatic --noinput + + +## NGINX setup +# Copy over only the static files from the previous stage +# to ensure a minimal image size in our NGINX container. +FROM nginx:alpine + +COPY --from=builder /var/www/pythondiscord.com /var/www/pythondiscord.com diff --git a/docker/pysite.dockerapp b/docker/pysite.dockerapp new file mode 100644 index 00000000..4a811861 --- /dev/null +++ b/docker/pysite.dockerapp @@ -0,0 +1,49 @@ +version: 0.1.0 +name: pysite +description: | + Our community website, built on Django and PostgreSQL. +#namespace: python-discord +maintainers: + - name: Johannes Christ + email: jc@jchri.st + +--- +version: "3.6" +services: + django: + image: registry.gitlab.com/python-discord/projects/site/django:latest + ports: + - "127.0.0.1:4000:4000" + environment: + DATABASE_URL: "postgres://${pg_user}:${pg_passwd}@${pg_host}/${pg_db}" + DEBUG: 0 + SECRET_KEY: "${secret_key}" + depends_on: + - migrator + - postgres + + postgres: + image: postgres:11-alpine + environment: + POSTGRES_DB: "${pg_db}" + POSTGRES_USER: "${pg_user}" + POSTGRES_PASSWORD: "${pg_passwd}" + + migrator: + image: registry.gitlab.com/python-discord/projects/site/django:latest + environment: + DATABASE_URL: "postgres://${pg_user}:${pg_passwd}@${pg_host}/${pg_db}" + DEBUG: 0 + SECRET_KEY: "${secret_key}" + command: "python manage.py migrate" + depends_on: + - postgres + +--- +pg_user: pysite +pg_db: pysite +pg_passwd: '' +pg_host: postgres +secret_key: 'suitable-for-development-only' + +# vim: ft=yaml: diff --git a/pysite.dockerapp b/pysite.dockerapp deleted file mode 100644 index 4a811861..00000000 --- a/pysite.dockerapp +++ /dev/null @@ -1,49 +0,0 @@ -version: 0.1.0 -name: pysite -description: | - Our community website, built on Django and PostgreSQL. -#namespace: python-discord -maintainers: - - name: Johannes Christ - email: jc@jchri.st - ---- -version: "3.6" -services: - django: - image: registry.gitlab.com/python-discord/projects/site/django:latest - ports: - - "127.0.0.1:4000:4000" - environment: - DATABASE_URL: "postgres://${pg_user}:${pg_passwd}@${pg_host}/${pg_db}" - DEBUG: 0 - SECRET_KEY: "${secret_key}" - depends_on: - - migrator - - postgres - - postgres: - image: postgres:11-alpine - environment: - POSTGRES_DB: "${pg_db}" - POSTGRES_USER: "${pg_user}" - POSTGRES_PASSWORD: "${pg_passwd}" - - migrator: - image: registry.gitlab.com/python-discord/projects/site/django:latest - environment: - DATABASE_URL: "postgres://${pg_user}:${pg_passwd}@${pg_host}/${pg_db}" - DEBUG: 0 - SECRET_KEY: "${secret_key}" - command: "python manage.py migrate" - depends_on: - - postgres - ---- -pg_user: pysite -pg_db: pysite -pg_passwd: '' -pg_host: postgres -secret_key: 'suitable-for-development-only' - -# vim: ft=yaml: -- cgit v1.2.3