diff --git a/.gitignore b/.gitignore index c92107cc4..8d4ecedd3 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,4 @@ staticfiles/ postgresql/ -/docker-compose.yml +/docker-compose.override.yml diff --git a/Dockerfile b/Dockerfile index 3f465dfb2..ab184cd32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 &&\ diff --git a/README.md b/README.md index be0aebf9d..1e8e27e44 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template new file mode 100644 index 000000000..0987be832 --- /dev/null +++ b/docker-compose.override.yml.template @@ -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 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..350e1c1c7 --- /dev/null +++ b/docker-compose.yml @@ -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: \ No newline at end of file diff --git a/docs/docker/nginx-proxy/README.md b/docs/docker/nginx-proxy/README.md index ceca1510c..521e4bfc6 100644 --- a/docs/docker/nginx-proxy/README.md +++ b/docs/docker/nginx-proxy/README.md @@ -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. \ No newline at end of file diff --git a/docs/docker/nginx-proxy/docker-compose.yml b/docs/docker/nginx-proxy/docker-compose.yml deleted file mode 100644 index e1c0e0119..000000000 --- a/docs/docker/nginx-proxy/docker-compose.yml +++ /dev/null @@ -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 diff --git a/docs/docker/plain/README.md b/docs/docker/plain/README.md new file mode 100644 index 000000000..fb7eb4302 --- /dev/null +++ b/docs/docker/plain/README.md @@ -0,0 +1 @@ +Just run docker-compose up in the root of this repository. \ No newline at end of file diff --git a/docs/docker/plain/docker-compose.yml b/docs/docker/plain/docker-compose.yml deleted file mode 100644 index cdde569b4..000000000 --- a/docs/docker/plain/docker-compose.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/docs/docker/traefik/README.md b/docs/docker/traefik/README.md index 7ebb14e32..17c0083cc 100644 --- a/docs/docker/traefik/README.md +++ b/docs/docker/traefik/README.md @@ -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 diff --git a/docs/docker/traefik/docker-compose.yml b/docs/docker/traefik/docker-compose.yml deleted file mode 100644 index c72b510f0..000000000 --- a/docs/docker/traefik/docker-compose.yml +++ /dev/null @@ -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