updated examples

This commit is contained in:
vabene1111 2020-03-24 16:44:19 +01:00
parent c67342df26
commit d7e0fa821b
9 changed files with 67 additions and 111 deletions

View File

@ -1,7 +1,3 @@
VIRTUAL_HOST=
LETSENCRYPT_HOST=
LETSENCRYPT_EMAIL=
DEBUG=1 DEBUG=1
ALLOWED_HOSTS=* ALLOWED_HOSTS=*
SECRET_KEY= SECRET_KEY=

View File

@ -1,46 +0,0 @@
# Uncomment and edit the services as you like in here
# there are several examples available
# The docker-compose.override.yml is merged with docker-compose.yml on runtime
#####################
# WITH NGINX-PROXY #
#####################
# version: "3"
# services:
# nginx_recipes:
# image: nginx:mainline-alpine
# restart: always
# env_file:
# - ./.env
# volumes:
# - ./nginx/conf.d:/etc/nginx/conf.d
# - ./staticfiles:/static
# - ./mediafiles:/media
# networks:
# - default
# - nginx-proxy
# networks:
# nginx-proxy:
# external:
# name: nginx-proxy
#######################
# WITH TREAFIK-PROXY #
#######################
# version: "3"
# services:
# web_recipes:
# labels: # This lables are only examples!
# - "traefik.enable=true"
# - "traefik.http.routers.recipes.rule=Host(`recipes.mydomain.com`, `recipes.myotherdomain.com`)"
# - "traefik.http.routers.recipes.entrypoints=web_secure"
# - "traefik.http.routers.recipes.tls.certresolver=le_resolver"
# networks:
# traefik: # This is you external traefic network
# external: true

View File

@ -1,29 +0,0 @@
version: "3"
services:
db_recipes:
restart: always
image: postgres:11-alpine
volumes:
- ./postgresql:/var/lib/postgresql/data
env_file:
- ./.env
networks:
- default
web_recipes:
build: .
restart: always
env_file:
- ./.env
volumes:
- ./staticfiles:/opt/recipes/staticfiles
- ./mediafiles:/opt/recipes/mediafiles
ports:
- 80:8080
depends_on:
- db_recipes
networks:
- default
networks:
default:

View File

@ -2,3 +2,10 @@ This is a docker compose example when using [jwilder's nginx reverse proxy](http
in combination with [jrcs's letsencrypt companion](https://hub.docker.com/r/jrcs/letsencrypt-nginx-proxy-companion/). in combination with [jrcs's letsencrypt companion](https://hub.docker.com/r/jrcs/letsencrypt-nginx-proxy-companion/).
Please refer to the appropriate documentation on how to setup the reverse proxy and networks. Please refer to the appropriate documentation on how to setup the reverse proxy and networks.
Remember to add the appropriate environment variables to `.env` file:
```
VIRTUAL_HOST=
LETSENCRYPT_HOST=
LETSENCRYPT_EMAIL=
```

View File

@ -1,5 +1,28 @@
version: "3" version: "3"
services: services:
db_recipes:
restart: always
image: postgres:11-alpine
volumes:
- ./postgresql:/var/lib/postgresql/data
env_file:
- ./.env
networks:
- default
web_recipes:
image: vabene1111/recipes:test
restart: always
env_file:
- ./.env
volumes:
- ./staticfiles:/opt/recipes/staticfiles
- ./mediafiles:/opt/recipes/mediafiles
depends_on:
- db_recipes
networks:
- default
nginx_recipes: nginx_recipes:
image: nginx:mainline-alpine image: nginx:mainline-alpine
restart: always restart: always
@ -14,6 +37,7 @@ services:
- nginx-proxy - nginx-proxy
networks: networks:
default:
nginx-proxy: nginx-proxy:
external: external:
name: nginx-proxy name: nginx-proxy

View File

@ -0,0 +1,5 @@
This is the most basic configuration to run this image with docker compose.
> **NOTE**: There is no proxy included in this configuration and gunicorn is directly exposed as the webserver which is
> not recommended by according to the [gunicorn devs](https://serverfault.com/questions/331256/why-do-i-need-nginx-and-something-like-gunicorn).
> It is higly recommended to configure an additional proxy (nginx, ...) in front of this.

View File

@ -7,9 +7,11 @@ services:
- ./postgresql:/var/lib/postgresql/data - ./postgresql:/var/lib/postgresql/data
env_file: env_file:
- ./.env - ./.env
networks:
- default
web_recipes: web_recipes:
build: . image: vabene1111/recipes:test
restart: always restart: always
env_file: env_file:
- ./.env - ./.env
@ -20,3 +22,8 @@ services:
- 80:8080 - 80:8080
depends_on: depends_on:
- db_recipes - db_recipes
networks:
- default
networks:
default:

View File

@ -2,39 +2,34 @@ version: "3"
services: services:
db_recipes: db_recipes:
restart: always restart: always
image: "postgres:11-alpine" image: postgres:11-alpine
volumes: volumes:
- ./postgresql:/var/lib/postgresql/data - ./postgresql:/var/lib/postgresql/data
env_file: env_file:
- ./.env - ./.env
networks:
- default
web_recipes: web_recipes:
build: . image: vabene1111/recipes:test
restart: always restart: always
env_file: env_file:
- ./.env - ./.env
command: "gunicorn --bind 0.0.0.0:8080 recipes.wsgi"
volumes: volumes:
- .:/Recipes - ./staticfiles:/opt/recipes/staticfiles
- ./mediafiles:/opt/recipes/mediafiles
depends_on: depends_on:
- db_recipes - db_recipes
labels: # This lables are only examples!
nginx_recipes:
image: "nginx"
restart: always
env_file:
- ./.env
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./staticfiles:/static
- ./mediafiles:/media
labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.recipes.rule=Host(`recipes.mydomain.com`, `recipes.myotherdomain.com`)" - "traefik.http.routers.recipes.rule=Host(`recipes.mydomain.com`, `recipes.myotherdomain.com`)"
- "traefik.http.routers.recipes.entrypoints=web_secure" - "traefik.http.routers.recipes.entrypoints=web_secure"
- "traefik.http.routers.recipes.tls.certresolver=le_resolver" - "traefik.http.routers.recipes.tls.certresolver=le_resolver"
networks:
- default
- traefik
networks: networks:
default: default:
external: traefik: # This is you external traefic network
name: traefik external: true

View File

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