Cleanup and simplify deployment

This commit is contained in:
h4llow3En 2020-03-19 15:08:53 +01:00
parent cc931189e8
commit 6b27f0c8ab
No known key found for this signature in database
GPG Key ID: E30BD90E953CCB30
11 changed files with 85 additions and 125 deletions

2
.gitignore vendored
View File

@ -76,4 +76,4 @@ staticfiles/
postgresql/
/docker-compose.yml
/docker-compose.override.yml

View File

@ -1,5 +1,6 @@
FROM python:3.8-alpine
# hadolint ignore=DL3018
RUN apk add --no-cache postgresql-libs gettext zlib libjpeg libxml2-dev libxslt-dev
ENV PYTHONUNBUFFERED 1
EXPOSE 8080
@ -14,6 +15,7 @@ COPY --chown=recipes:recipes . ./
RUN pwd && ls -lha
RUN chmod +x boot.sh
# hadolint ignore=DL3018
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev && \
python -m venv venv && \
venv/bin/pip install -r requirements.txt --no-cache-dir &&\

View File

@ -48,11 +48,10 @@ When clicking submit, every recipe containing the word will be updated (tags are
### Docker-Compose
1. Clone this repository to your desired install location
2. Choose one of the included `docker-compose.yml` files [here](https://github.com/vabene1111/recipes/tree/develop/docs/docker).
3. Copy it to the root directory (where this readme is)
2. Choose one of the included configurations [here](https://github.com/vabene1111/recipes/tree/develop/docs/docker).
3. Copy (if needed) the `docker-compose.override.yml.template` to `docker-compose.override.yml` and uncomment the configurations you need.
4. Start the container (`docker-compose up -d`)
5. This time and **on each update** run `update.sh` to apply migrations and collect static files
6. Create a default user by executing into the container with `docker-compose exec web_recipes sh` and run `python3 manage.py createsuperuser`.
5. Create a default user by executing into the container with `docker-compose exec web_recipes sh` and run `python3 manage.py createsuperuser`.
### Manual
Copy `.env.template` to `.env` and fill in the missing values accordingly.

View File

@ -0,0 +1,46 @@
# 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"
# 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

29
docker-compose.yml Normal file
View File

@ -0,0 +1,29 @@
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,5 @@ 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/).
Please refer to the appropriate documentation on how to setup the reverse proxy and networks.
Copy the docker-compose.override.yml.template and uncomment the corresponding part.

View File

@ -1,43 +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
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

View File

@ -0,0 +1 @@
Just run docker-compose up in the root of this repository.

View File

@ -1,37 +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
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
ports:
- 80:80
networks:
- default
depends_on:
- web_recipes

View File

@ -1,6 +1,7 @@
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.
Copy the docker-compose.override.yml.template and uncomment the corresponding part.
You need to create a network called `traefik` using `docker network create traefik`.
## docker-compose.yml

View File

@ -1,40 +0,0 @@
version: "3"
services:
db_recipes:
restart: always
image: "postgres:11-alpine"
volumes:
- ./postgresql:/var/lib/postgresql/data
env_file:
- ./.env
web_recipes:
build: .
restart: always
env_file:
- ./.env
command: "gunicorn --bind 0.0.0.0:8080 recipes.wsgi"
volumes:
- .:/Recipes
depends_on:
- db_recipes
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.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:
external:
name: traefik