First successful deployment
This commit is contained in:
parent
f3e6a53cfd
commit
c5691f5e88
6 changed files with 40 additions and 113 deletions
43
Dockerfile
43
Dockerfile
|
@ -1,4 +1,4 @@
|
|||
# Original file from: https://github.com/dockerfiles/django-uwsgi-nginx
|
||||
# Original file from: https://github.com/appfiles/django-uwsgi-nginx
|
||||
# Copyright 2013 Thatcher Peskens
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,34 +15,31 @@
|
|||
|
||||
FROM alpine:3.8
|
||||
|
||||
MAINTAINER Dockerfiles
|
||||
MAINTAINER Claudio Maggioni (praticamentetilde)
|
||||
|
||||
# Install required packages and remove the apt packages cache when done.
|
||||
RUN addgroup -S app && adduser -S -G app app
|
||||
|
||||
RUN apk add -y
|
||||
# Install required packages and remove the apt packages cache when done
|
||||
RUN apk update && apk add \
|
||||
uwsgi \
|
||||
py3-psycopg2 \
|
||||
uwsgi-python3 \
|
||||
git \
|
||||
python3 \
|
||||
python3-dev \
|
||||
nginx \
|
||||
supervisor \
|
||||
pip3 install -U pip setuptools
|
||||
python3-dev
|
||||
|
||||
# install uwsgi now because it takes a little while
|
||||
RUN pip3 install uwsgi
|
||||
# COPY requirements.txt and RUN pip install BEFORE adding the rest of your
|
||||
# code, this will cause Docker's caching mechanism to prevent re-installing
|
||||
# (all your) dependencies when you made a change a line or two in your app.
|
||||
|
||||
# setup all the configfiles
|
||||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
|
||||
COPY nginx-app.conf /etc/nginx/sites-available/default
|
||||
COPY supervisor-app.conf /etc/supervisor/conf.d/
|
||||
|
||||
# COPY requirements.txt and RUN pip install BEFORE adding the rest of your code, this will cause Docker's caching mechanism
|
||||
# to prevent re-installing (all your) dependencies when you made a change a line or two in your app.
|
||||
|
||||
COPY requirements.txt /home/docker/code/
|
||||
RUN pip3 install -r /home/docker/code/requirements.txt
|
||||
COPY requirements.txt /home/app/code/
|
||||
RUN pip3 install -r /home/app/code/requirements.txt
|
||||
|
||||
# add (the rest of) our code
|
||||
COPY . /home/docker/code/
|
||||
COPY . /home/app/code/
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["supervisord", "-n"]
|
||||
RUN chown -R app: /home/app
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["/usr/sbin/uwsgi", "--ini", "/home/app/code/uwsgi.ini", "--plugin", "python3"]
|
||||
USER app
|
||||
|
|
|
@ -20,12 +20,12 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'x7umjf5-9w*9iqb6p+9dy+7%66p=1xau+6kieblqvft*o=@)p#'
|
||||
SECRET_KEY = os.environ["SECURITY_KEY"]
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = os.environ["DEBUG"] == "true"
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
ALLOWED_HOSTS = os.environ["ALLOWED_HOSTS"].split()
|
||||
|
||||
AUTH_USER_MODEL = 'user.CounterUser'
|
||||
|
||||
|
@ -48,7 +48,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django_extensions'
|
||||
# 'django_extensions'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -89,10 +89,10 @@ WSGI_APPLICATION = 'arrowcounter.wsgi.application'
|
|||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'arrowcounter',
|
||||
'USER': 'arrowcounter',
|
||||
'PASSWORD': 'password',
|
||||
'HOST': 'localhost',
|
||||
'NAME': os.environ["POSTGRES_DB"],
|
||||
'USER': os.environ["POSTGRES_USER"],
|
||||
'PASSWORD': os.environ["POSTGRES_PASSWORD"],
|
||||
'HOST': os.environ["POSTGRES_HOST"],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
# nginx-app.conf
|
||||
|
||||
# the upstream component nginx needs to connect to
|
||||
upstream django {
|
||||
server unix:/home/docker/code/app.sock; # for a file socket
|
||||
# server 127.0.0.1:8001; # for a web port socket (we'll use this first)
|
||||
}
|
||||
|
||||
# configuration of the server
|
||||
server {
|
||||
# the port your site will be served on, default_server indicates that this server block
|
||||
# is the block to use if no blocks match the server_name
|
||||
listen 80 default_server;
|
||||
|
||||
# the domain name it will serve for
|
||||
server_name .example.com; # substitute your machine's IP address or FQDN
|
||||
charset utf-8;
|
||||
|
||||
# max upload size
|
||||
client_max_body_size 75M; # adjust to taste
|
||||
|
||||
# Django media
|
||||
location /media {
|
||||
alias /home/docker/persistent/media; # your Django project's media files - amend as required
|
||||
}
|
||||
|
||||
location /static {
|
||||
alias /home/docker/volatile/static; # your Django project's static files - amend as required
|
||||
}
|
||||
|
||||
# Finally, send all non-media requests to the Django server.
|
||||
location / {
|
||||
uwsgi_pass django;
|
||||
include /home/docker/code/uwsgi_params; # the uwsgi_params file you installed
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
[program:app-uwsgi]
|
||||
command = /usr/local/bin/uwsgi --ini /home/docker/code/uwsgi.ini
|
||||
|
||||
[program:nginx-app]
|
||||
command = /usr/sbin/nginx
|
37
uwsgi.ini
37
uwsgi.ini
|
@ -1,31 +1,18 @@
|
|||
[uwsgi]
|
||||
# this config will be loaded if nothing specific is specified
|
||||
# load base config from below
|
||||
ini = :base
|
||||
# chdir to the folder of this config file
|
||||
chdir = %d/
|
||||
|
||||
# %d is the dir this configuration file is in
|
||||
socket = %dapp.sock
|
||||
# load Django's wsgi.py for this application
|
||||
module = arrowcounter.wsgi:application
|
||||
|
||||
# serve static files under app static dirs
|
||||
static-map2 = /static=%d/counter
|
||||
static-map2 = /static=%d/user
|
||||
static-expires = /* 7776000
|
||||
offload-threads = %k
|
||||
|
||||
socket = 0.0.0.0:8000
|
||||
master = true
|
||||
processes = 4
|
||||
|
||||
[dev]
|
||||
ini = :base
|
||||
# socket (uwsgi) is not the same as http, nor http-socket
|
||||
socket = :8001
|
||||
|
||||
|
||||
[local]
|
||||
ini = :base
|
||||
http = :8000
|
||||
# set the virtual env to use
|
||||
home=/Users/you/envs/env
|
||||
|
||||
|
||||
[base]
|
||||
# chdir to the folder of this config file, plus app/website
|
||||
chdir = %d/
|
||||
# load the module from wsgi.py, it is a python path from
|
||||
# the directory above.
|
||||
module=website.wsgi:application
|
||||
# allow anyone to connect to the socket. This is very permissive
|
||||
chmod-socket=666
|
||||
|
|
16
uwsgi_params
16
uwsgi_params
|
@ -1,16 +0,0 @@
|
|||
|
||||
uwsgi_param QUERY_STRING $query_string;
|
||||
uwsgi_param REQUEST_METHOD $request_method;
|
||||
uwsgi_param CONTENT_TYPE $content_type;
|
||||
uwsgi_param CONTENT_LENGTH $content_length;
|
||||
|
||||
uwsgi_param REQUEST_URI $request_uri;
|
||||
uwsgi_param PATH_INFO $document_uri;
|
||||
uwsgi_param DOCUMENT_ROOT $document_root;
|
||||
uwsgi_param SERVER_PROTOCOL $server_protocol;
|
||||
uwsgi_param HTTPS $https if_not_empty;
|
||||
|
||||
uwsgi_param REMOTE_ADDR $remote_addr;
|
||||
uwsgi_param REMOTE_PORT $remote_port;
|
||||
uwsgi_param SERVER_PORT $server_port;
|
||||
uwsgi_param SERVER_NAME $server_name;
|
Loading…
Reference in a new issue