-
-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f24b7d
commit 9ac3d79
Showing
7 changed files
with
142 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
This is the recommended setup to run django recipes with traefik. | ||
|
||
---- | ||
|
||
Please refer to the traefik documentation on how to setup a docker service in traefik. Since treafik can be a little | ||
confusing at times, the following are examples of my traefik configuration. | ||
|
||
|
||
You need to create a network called `traefik` using `docker network create traefik`. | ||
## docker-compose.yml | ||
|
||
``` | ||
version: "3.3" | ||
services: | ||
traefik: | ||
image: "traefik:v2.1" | ||
container_name: "traefik" | ||
ports: | ||
- "443:443" | ||
- "80:80" | ||
- "8080:8080" | ||
volumes: | ||
- "./letsencrypt:/letsencrypt" | ||
- "/var/run/docker.sock:/var/run/docker.sock:ro" | ||
- "./config:/etc/traefik/" | ||
networks: | ||
default: | ||
external: | ||
name: traefik | ||
``` | ||
|
||
## traefik.toml | ||
Place this in a directory called `config` as this is mounted into the traefik container (see docer compose). | ||
**Change the email address accordingly**. | ||
``` | ||
[api] | ||
insecure=true | ||
[providers.docker] | ||
endpoint = "unix:///var/run/docker.sock" | ||
exposedByDefault = false | ||
network = "traefik" | ||
#[log] | ||
# level = "DEBUG" | ||
[entryPoints] | ||
[entryPoints.web] | ||
address = ":80" | ||
[entryPoints.web_secure] | ||
address = ":443" | ||
[certificatesResolvers.le_resolver.acme] | ||
email = "[email protected]" | ||
storage = "/letsencrypt/acme.json" | ||
tlsChallenge=true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
version: "3" | ||
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 | ||
restart: always | ||
env_file: | ||
- ./.env | ||
volumes: | ||
- ./staticfiles:/opt/recipes/staticfiles | ||
- ./mediafiles:/opt/recipes/mediafiles | ||
depends_on: | ||
- db_recipes | ||
networks: | ||
- default | ||
|
||
nginx_recipes: | ||
image: nginx:mainline-alpine | ||
restart: always | ||
env_file: | ||
- ./.env | ||
volumes: | ||
- ./nginx/conf.d:/etc/nginx/conf.d | ||
- ./mediafiles:/media | ||
labels: # traefik example labels | ||
- "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: | ||
- default | ||
- traefik | ||
|
||
networks: | ||
default: | ||
traefik: # This is you external traefik network | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
client_max_body_size 16M; | ||
|
||
# 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters