initial docker setup for staging now works

This commit is contained in:
Oliver Marks 2017-02-01 22:26:13 +00:00 committed by Oly
parent 411dedf00d
commit 9faf03f1e7
11 changed files with 109 additions and 19 deletions

View File

@ -11,6 +11,7 @@ RUN pip install -r /requirements/production.txt \
COPY . /app COPY . /app
RUN chown -R django /app RUN chown -R django /app
RUN mkdir -p /data/sockets
COPY ./compose/django/gunicorn.sh /gunicorn.sh COPY ./compose/django/gunicorn.sh /gunicorn.sh
COPY ./compose/django/entrypoint.sh /entrypoint.sh COPY ./compose/django/entrypoint.sh /entrypoint.sh
@ -19,7 +20,8 @@ RUN sed -i 's/\r//' /entrypoint.sh \
&& chmod +x /entrypoint.sh \ && chmod +x /entrypoint.sh \
&& chown django /entrypoint.sh \ && chown django /entrypoint.sh \
&& chmod +x /gunicorn.sh \ && chmod +x /gunicorn.sh \
&& chown django /gunicorn.sh && chown django /gunicorn.sh \
&& chown django /data/sockets
WORKDIR /app WORKDIR /app

View File

@ -1,3 +1,6 @@
#!/bin/sh #!/bin/sh
python /app/manage.py collectstatic --noinput python /app/manage.py collectstatic --noinput
chmod 777 -R /data/sockets/
touch /data/sockets/gunicron.sock
ls -la /data/sockets/
/usr/local/bin/gunicorn config.wsgi -w 4 -b unix:/data/sockets/gunicorn.sock --chdir=/app /usr/local/bin/gunicorn config.wsgi -w 4 -b unix:/data/sockets/gunicorn.sock --chdir=/app

View File

@ -26,7 +26,8 @@ http {
#gzip on; #gzip on;
upstream app { upstream app {
server django:5000; #server django:5000;
server unix:/data/sockets/gunicorn.sock;
} }
server { server {
@ -36,12 +37,12 @@ http {
server_name ___my.example.com___ ; server_name ___my.example.com___ ;
location /.well-known/acme-challenge { # location /.well-known/acme-challenge {
proxy_pass http://certbot:80; # proxy_pass http://certbot:80;
proxy_set_header Host $host; # proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr; # proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https; # proxy_set_header X-Forwarded-Proto https;
} # }
location / { location / {

View File

@ -189,6 +189,7 @@ STATICFILES_DIRS = (
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'sass_processor.finders.CssFinder',
) )
# MEDIA CONFIGURATION # MEDIA CONFIGURATION
@ -252,7 +253,7 @@ LOGIN_URL = 'account_login'
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify' AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
# django-compressor # django-compressor
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
INSTALLED_APPS += ("compressor", ) INSTALLED_APPS += ("compressor", 'sass_processor',)
STATICFILES_FINDERS += ("compressor.finders.CompressorFinder", ) STATICFILES_FINDERS += ("compressor.finders.CompressorFinder", )
# Location of root django.contrib.admin URL, use {% url 'admin:index' %} # Location of root django.contrib.admin URL, use {% url 'admin:index' %}

View File

@ -56,6 +56,9 @@ X_FRAME_OPTIONS = 'DENY'
# Hosts/domain names that are valid for this site # Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts # See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['maidstone-hackspace.org.uk']) ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['maidstone-hackspace.org.uk'])
ALLOWED_HOSTS.append('172.*')
ALLOWED_HOSTS.append('172.18.0.5')
# END SITE CONFIGURATION # END SITE CONFIGURATION
INSTALLED_APPS += ('gunicorn', ) INSTALLED_APPS += ('gunicorn', )

View File

@ -1,9 +1,20 @@
version: '2' version: '2'
volumes: volumes:
gunicorn_socket: {} gunicorn_socket:
postgres_data: {} driver: local
postgres_backup: {} postgres_data:
driver: local
postgres_backup:
driver: local
# volumes:
# sockets:
# driver: local
# data:
# driver: local
services: services:
postgres: postgres:
@ -25,10 +36,11 @@ services:
env_file: .env env_file: .env
volumes: volumes:
- .:/app - .:/app
- gunicorn_socket:/data/sockets/ - gunicorn_socket:/data/sockets
nginx: nginx:
build: ./compose/nginx build: ./compose/nginx
env_file: .env
depends_on: depends_on:
- django - django
# - certbot # - certbot
@ -37,6 +49,9 @@ services:
- MY_DOMAIN_NAME=maidstone-hackspace.org.uk - MY_DOMAIN_NAME=maidstone-hackspace.org.uk
ports: ports:
- "0.0.0.0:80:80" - "0.0.0.0:80:80"
volumes:
- .:/app
- gunicorn_socket:/data/sockets
# - "0.0.0.0:443:443" # - "0.0.0.0:443:443"
# volumes: # volumes:
# - /etc/letsencrypt:/etc/letsencrypt # - /etc/letsencrypt:/etc/letsencrypt

55
live.yml Normal file
View File

@ -0,0 +1,55 @@
version: '2'
volumes:
gunicorn_socket: {}
postgres_data_dev: {}
postgres_backup_dev: {}
services:
postgres:
build: ./compose/postgres
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- postgres_backup_dev:/backups
# environment:
# - POSTGRES_USER=${POSTGRES_USER}
env_file: .env
django:
build:
context: .
dockerfile: ./compose/django/Dockerfile
command: /start-dev.sh
depends_on:
- postgres
environment:
- POSTGRES_USER=${POSTGRES_USER}
- USE_DOCKER=yes
volumes:
- .:/app
- gunicorn_socket:/var/run/gunicorn/
ports:
- "8180:8000"
links:
- postgres
- mailhog
nginx:
build: ./compose/nginx
depends_on:
- django
environment:
- MY_DOMAIN_NAME=maidstone-hackspace.org.uk
ports:
- "0.0.0.0:80:80"
# - "0.0.0.0:443:443"
volumes:
- gunicorn_socket:/var/run/gunicorn/
mailhog:
image: mailhog/mailhog
ports:
- "8125:8025"
redis:
image: redis:latest

View File

@ -370,8 +370,6 @@ class payment:
print('---------------------') print('---------------------')
print(args) print(args)
from pprint import pprint from pprint import pprint
if self.provider == 'paypal': if self.provider == 'paypal':
print(args.get('paymentId')) print(args.get('paymentId'))

View File

@ -91,8 +91,21 @@
</nav> </nav>
</div> </div>
<ul class="nav flex-column navbar-left" style="position:absolute;top:30px;">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<div class="container"> <div class="container">
{% if messages %} {% if messages %}
{% for message in messages %} {% for message in messages %}
<div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">{{ message }}</div> <div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">{{ message }}</div>

View File

@ -42,10 +42,9 @@ django-redis==4.7.0
redis>=2.10.5 redis>=2.10.5
rcssmin==1.0.6 rcssmin==1.0.6
django-compressor==2.1 django-compressor==2.1
django-sass-processor
lxml==3.7.2 lxml==3.7.2
mock mock

0
staticfiles/staticfiles Normal file
View File