Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous Integration - Continuous Deployment #37

Merged
merged 7 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
3 changes: 3 additions & 0 deletions project/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VIRTUAL_HOST=VIRTUAL_HOST_NAME_HERE
LETSENCRYPT_HOST=HOST_NAME_HERE
LETSENCRYPT_EMAIL=LETSENCRYPT_EMAIL_HERE
53 changes: 53 additions & 0 deletions project/docker-compose-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: "2"

services:
nginx:
restart: always
image: nginx
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/conf.d"
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "./volumes/proxy/certs:/etc/nginx/certs:ro"

nginx-gen:
restart: always
image: jwilder/docker-gen
container_name: nginx-gen
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "./volumes/proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf

letsencrypt-nginx-proxy-companion:
restart: always
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
volumes_from:
- nginx
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./volumes/proxy/certs:/etc/nginx/certs:rw"
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen

sample-website:
build: ./project
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
container_name: website
volumes:
- ./project:/code
ports:
- "8000:8000"
environment:
- VIRTUAL_HOST=${VIRTUAL_HOST}
- VIRTUAL_NETWORK=nginx-proxy
- VIRTUAL_PORT=8000
- LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
2 changes: 1 addition & 1 deletion project/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.9"
version: "3.2"

services:
web:
Expand Down
3 changes: 2 additions & 1 deletion project/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Django>=3.0,<4.0
psycopg2-binary>=2.8
psycopg2-binary>=2.8
django-environ>=0.8.1
3 changes: 3 additions & 0 deletions project/yahtzee/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SECRET_KEY=SECRET_GOES_HERE
ALLOWED_HOSTS=HOST_URL_HERE
DEBUG=DEBUG_FLAG
Binary file modified project/yahtzee/__pycache__/settings.cpython-310.pyc
Binary file not shown.
12 changes: 9 additions & 3 deletions project/yahtzee/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
import environ
from pathlib import Path
from . import frontend

# Initialize environment variables
env = environ.Env()

environ.Env.read_env()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand All @@ -21,12 +27,12 @@
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-t$vmv0+k-nz%)s06cb)%v2#@43&=zj%z&u46_-dp!^v1w+vyvc'
SECRET_KEY = env('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = env('DEBUG')

ALLOWED_HOSTS = []
ALLOWED_HOSTS = [env('ALLOWED_HOSTS')]


# Application definition
Expand Down