Make deploys great again
This commit is contained in:
parent
a95d3cde9b
commit
e1a9fc75d2
10 changed files with 47 additions and 132 deletions
36
.envs/.production/.django
Normal file
36
.envs/.production/.django
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# General
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# DJANGO_READ_DOT_ENV_FILE=True
|
||||||
|
DJANGO_SETTINGS_MODULE=config.settings.production
|
||||||
|
DJANGO_SECRET_KEY=MXZhW31sbiCJhpSUqXN3ugX90QkwJy0uDo1h7ydscnjazI4oTCtR7DudOrFtbst6
|
||||||
|
DJANGO_ADMIN_URL=3sBp3cf4l4q6OHhT058jZq4VrM5Spdpo/
|
||||||
|
DJANGO_ALLOWED_HOSTS=.qabel.de,localhost
|
||||||
|
|
||||||
|
# Security
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# TIP: better off using DNS, however, redirect is OK too
|
||||||
|
DJANGO_SECURE_SSL_REDIRECT=False
|
||||||
|
|
||||||
|
# Email
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
MAILGUN_API_KEY=
|
||||||
|
DJANGO_SERVER_EMAIL=
|
||||||
|
MAILGUN_DOMAIN=
|
||||||
|
|
||||||
|
# django-allauth
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
DJANGO_ACCOUNT_ALLOW_REGISTRATION=True
|
||||||
|
|
||||||
|
# django-compressor
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
COMPRESS_ENABLED=
|
||||||
|
|
||||||
|
# Gunicorn
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
WEB_CONCURRENCY=4
|
||||||
|
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
REDIS_URL=redis://redis:6379/0
|
||||||
|
|
7
.envs/.production/.postgres
Normal file
7
.envs/.production/.postgres
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# PostgreSQL
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
POSTGRES_HOST=postgres
|
||||||
|
POSTGRES_PORT=5432
|
||||||
|
POSTGRES_DB=schickmacher
|
||||||
|
POSTGRES_USER=bveRqqyWHjzJdittTvcxxnqrGdXBtDOh
|
||||||
|
POSTGRES_PASSWORD=y8fXgQPcgpHf96iApeLaXWLZcfNiUGVdHatBFnxIrsP9dQOB9z8iCPc5sDXJAqzk
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -330,3 +330,4 @@ schickmacher/media/
|
||||||
.env
|
.env
|
||||||
.envs/*
|
.envs/*
|
||||||
!.envs/.local/
|
!.envs/.local/
|
||||||
|
!.envs/.production/
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
FROM garland/aws-cli-docker:1.15.47
|
|
||||||
|
|
||||||
COPY ./compose/production/aws/maintenance /usr/local/bin/maintenance
|
|
||||||
COPY ./compose/production/postgres/maintenance/_sourced /usr/local/bin/maintenance/_sourced
|
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/maintenance/*
|
|
||||||
|
|
||||||
RUN mv /usr/local/bin/maintenance/* /usr/local/bin \
|
|
||||||
&& rmdir /usr/local/bin/maintenance
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
### Download a file from your Amazon S3 bucket to the postgres /backups folder
|
|
||||||
###
|
|
||||||
### Usage:
|
|
||||||
### $ docker-compose -f production.yml run --rm awscli <1>
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o pipefail
|
|
||||||
set -o nounset
|
|
||||||
|
|
||||||
working_dir="$(dirname ${0})"
|
|
||||||
source "${working_dir}/_sourced/constants.sh"
|
|
||||||
source "${working_dir}/_sourced/messages.sh"
|
|
||||||
|
|
||||||
export AWS_ACCESS_KEY_ID="${DJANGO_AWS_ACCESS_KEY_ID}"
|
|
||||||
export AWS_SECRET_ACCESS_KEY="${DJANGO_AWS_SECRET_ACCESS_KEY}"
|
|
||||||
export AWS_STORAGE_BUCKET_NAME="${DJANGO_AWS_STORAGE_BUCKET_NAME}"
|
|
||||||
|
|
||||||
|
|
||||||
aws s3 cp s3://${AWS_STORAGE_BUCKET_NAME}${BACKUP_DIR_PATH}/${1} ${BACKUP_DIR_PATH}/${1}
|
|
||||||
|
|
||||||
message_success "Finished downloading ${1}."
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
### Upload the /backups folder to Amazon S3
|
|
||||||
###
|
|
||||||
### Usage:
|
|
||||||
### $ docker-compose -f production.yml run --rm awscli upload
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o pipefail
|
|
||||||
set -o nounset
|
|
||||||
|
|
||||||
working_dir="$(dirname ${0})"
|
|
||||||
source "${working_dir}/_sourced/constants.sh"
|
|
||||||
source "${working_dir}/_sourced/messages.sh"
|
|
||||||
|
|
||||||
export AWS_ACCESS_KEY_ID="${DJANGO_AWS_ACCESS_KEY_ID}"
|
|
||||||
export AWS_SECRET_ACCESS_KEY="${DJANGO_AWS_SECRET_ACCESS_KEY}"
|
|
||||||
export AWS_STORAGE_BUCKET_NAME="${DJANGO_AWS_STORAGE_BUCKET_NAME}"
|
|
||||||
|
|
||||||
|
|
||||||
message_info "Upload the backups directory to S3 bucket {$AWS_STORAGE_BUCKET_NAME}"
|
|
||||||
|
|
||||||
aws s3 cp ${BACKUP_DIR_PATH} s3://${AWS_STORAGE_BUCKET_NAME}${BACKUP_DIR_PATH} --recursive
|
|
||||||
|
|
||||||
message_info "Cleaning the directory ${BACKUP_DIR_PATH}"
|
|
||||||
|
|
||||||
rm -rf ${BACKUP_DIR_PATH}/*
|
|
||||||
|
|
||||||
message_success "Finished uploading and cleaning."
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
FROM traefik:alpine
|
|
||||||
RUN mkdir -p /etc/traefik/acme
|
|
||||||
RUN touch /etc/traefik/acme/acme.json
|
|
||||||
RUN chmod 600 /etc/traefik/acme/acme.json
|
|
||||||
COPY ./compose/production/traefik/traefik.toml /etc/traefik
|
|
|
@ -1,41 +0,0 @@
|
||||||
logLevel = "INFO"
|
|
||||||
defaultEntryPoints = ["http", "https"]
|
|
||||||
|
|
||||||
# Entrypoints, http and https
|
|
||||||
[entryPoints]
|
|
||||||
# http should be redirected to https
|
|
||||||
[entryPoints.http]
|
|
||||||
address = ":80"
|
|
||||||
[entryPoints.http.redirect]
|
|
||||||
entryPoint = "https"
|
|
||||||
# https is the default
|
|
||||||
[entryPoints.https]
|
|
||||||
address = ":443"
|
|
||||||
[entryPoints.https.tls]
|
|
||||||
|
|
||||||
# Enable ACME (Let's Encrypt): automatic SSL
|
|
||||||
[acme]
|
|
||||||
# Email address used for registration
|
|
||||||
email = "kadenbach@qabel.de"
|
|
||||||
storage = "/etc/traefik/acme/acme.json"
|
|
||||||
entryPoint = "https"
|
|
||||||
onDemand = false
|
|
||||||
OnHostRule = true
|
|
||||||
# Use a HTTP-01 acme challenge rather than TLS-SNI-01 challenge
|
|
||||||
[acme.httpChallenge]
|
|
||||||
entryPoint = "http"
|
|
||||||
|
|
||||||
[file]
|
|
||||||
[backends]
|
|
||||||
[backends.django]
|
|
||||||
[backends.django.servers.server1]
|
|
||||||
url = "http://django:5000"
|
|
||||||
|
|
||||||
[frontends]
|
|
||||||
[frontends.django]
|
|
||||||
backend = "django"
|
|
||||||
passHostHeader = true
|
|
||||||
[frontends.django.headers]
|
|
||||||
HostsProxyHeaders = ['X-CSRFToken']
|
|
||||||
[frontends.django.routes.dr1]
|
|
||||||
rule = "Host:qabel.de"
|
|
|
@ -105,7 +105,7 @@ ANYMAIL = {
|
||||||
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
|
||||||
COMPRESS_ENABLED = env.bool("COMPRESS_ENABLED", default=True)
|
COMPRESS_ENABLED = env.bool("COMPRESS_ENABLED", default=True)
|
||||||
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
|
||||||
COMPRESS_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
|
# COMPRESS_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
|
||||||
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL
|
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL
|
||||||
COMPRESS_URL = STATIC_URL # noqa F405
|
COMPRESS_URL = STATIC_URL # noqa F405
|
||||||
# Collectfast
|
# Collectfast
|
||||||
|
|
|
@ -3,7 +3,6 @@ version: '3'
|
||||||
volumes:
|
volumes:
|
||||||
production_postgres_data: {}
|
production_postgres_data: {}
|
||||||
production_postgres_data_backups: {}
|
production_postgres_data_backups: {}
|
||||||
production_traefik: {}
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
django:
|
django:
|
||||||
|
@ -18,6 +17,8 @@ services:
|
||||||
- ./.envs/.production/.django
|
- ./.envs/.production/.django
|
||||||
- ./.envs/.production/.postgres
|
- ./.envs/.production/.postgres
|
||||||
command: /start
|
command: /start
|
||||||
|
ports:
|
||||||
|
- "8000:5000"
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
build:
|
build:
|
||||||
|
@ -30,26 +31,5 @@ services:
|
||||||
env_file:
|
env_file:
|
||||||
- ./.envs/.production/.postgres
|
- ./.envs/.production/.postgres
|
||||||
|
|
||||||
traefik:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: ./compose/production/traefik/Dockerfile
|
|
||||||
image: schickmacher_production_traefik
|
|
||||||
depends_on:
|
|
||||||
- django
|
|
||||||
volumes:
|
|
||||||
- production_traefik:/etc/traefik/acme
|
|
||||||
ports:
|
|
||||||
- "0.0.0.0:80:80"
|
|
||||||
- "0.0.0.0:443:443"
|
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:5.0
|
image: redis:5.0
|
||||||
awscli:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: ./compose/production/aws/Dockerfile
|
|
||||||
env_file:
|
|
||||||
- ./.envs/.production/.django
|
|
||||||
volumes:
|
|
||||||
- production_postgres_data_backups:/backups
|
|
||||||
|
|
Loading…
Reference in a new issue