docker first try

This commit is contained in:
vabene1111 2018-11-07 13:31:26 +01:00
parent be32b3f63e
commit 484f7c556e
7 changed files with 113 additions and 0 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
node_modules
npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode

8
.env.secret.template Normal file
View File

@ -0,0 +1,8 @@
DEBUG=1
ALLOWED_HOSTS=*
SECRET_KEY=
POSTGRES_HOST=db_recipes
POSTGRES_PORT=5432
POSTGRES_USER=djangodb
POSTGRES_PASSWORD=
POSTGRES_DB=djangodb

3
.env.template Normal file
View File

@ -0,0 +1,3 @@
VIRTUAL_HOST=
LETSENCRYPT_HOST=
LETSENCRYPT_EMAIL=

29
Dockerfile Normal file
View File

@ -0,0 +1,29 @@
FROM alpine
# Project Files and Settings
RUN mkdir /Recipes
WORKDIR /Recipes
ADD . /Recipes/
RUN apk update
RUN apk upgrade
RUN apk --no-cache add \
python3 \
python3-dev \
postgresql-client \
postgresql-dev \
build-base \
gettext
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
RUN apk del -r python3-dev
ENV PYTHONUNBUFFERED 1
# Server
EXPOSE 8080

43
docker-compose.yml Normal file
View File

@ -0,0 +1,43 @@
version: "3"
services:
db_recipes:
restart: always
image: "postgres:10.3-alpine"
volumes:
- /usr/src/recipes/postgresql:/var/lib/postgresql/data
env_file:
- ./.env.secret
networks:
- default
web_recipes:
build: .
restart: always
env_file:
- ./.env.secret
command: "gunicorn --bind 0.0.0.0:8080 Recipes.wsgi"
volumes:
- .:/Recipes
depends_on:
- db_recipes
networks:
- default
nginx_recipes:
image: "nginx"
restart: always
env_file:
- ./.env
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./staticfiles:/static
- ./mediafiles:/media
networks:
- default
- nginx-proxy
networks:
default:
nginx-proxy:
external:
name: nginx-proxy

17
nginx/conf.d/Recipes.conf Normal file
View File

@ -0,0 +1,17 @@
server {
listen 80;
server_name localhost;
# serve static files
location /static/ {
alias /static/;
}
# serve media files
location /media/ {
alias /media/;
}
# pass requests for dynamic content to gunicorn
location / {
proxy_set_header Host $host;
proxy_pass http://web_recipes:8080;
}
}

3
update.sh Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
docker-compose run web_recipes python3 manage.py migrate
docker-compose run web_recipes python3 manage.py collectstatic