From 8c3d413537b3b4f05ba99e409e25547a2f60a337 Mon Sep 17 00:00:00 2001 From: aptalca Date: Sun, 3 Apr 2022 20:50:33 -0400 Subject: [PATCH 1/3] rebase to nginx for static assets --- Dockerfile | 5 ++--- Dockerfile.aarch64 | 4 ++-- Dockerfile.armhf | 4 ++-- README.md | 1 + readme-vars.yml | 1 + root/defaults/default | 20 ++++++++++++++++++++ root/etc/cont-init.d/30-config | 2 +- root/etc/services.d/babybuddy/run | 2 +- 8 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 root/defaults/default diff --git a/Dockerfile b/Dockerfile index a45ccb6..4d0dbe5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:3.14 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.14 # set version label ARG BUILD_DATE @@ -44,8 +44,7 @@ RUN \ cd /app/babybuddy && \ pip3 install -U --no-cache-dir \ pip && \ - pip install lxml --no-binary :all: && \ - pip install -U --ignore-installed --find-links https://wheel-index.linuxserver.io/alpine/ -r requirements.txt && \ + pip install --no-cache-dir --ignore-installed --find-links https://wheel-index.linuxserver.io/alpine/ -r requirements.txt && \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 0421df9..4e7554f 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.14 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.14 # set version label ARG BUILD_DATE @@ -44,7 +44,7 @@ RUN \ cd /app/babybuddy && \ pip3 install -U --no-cache-dir \ pip && \ - pip install -U --ignore-installed --find-links https://wheel-index.linuxserver.io/alpine/ -r requirements.txt && \ + pip install --no-cache-dir --ignore-installed --find-links https://wheel-index.linuxserver.io/alpine/ -r requirements.txt && \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 97b4df6..f63c3b3 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.14 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.14 # set version label ARG BUILD_DATE @@ -44,7 +44,7 @@ RUN \ cd /app/babybuddy && \ pip3 install -U --no-cache-dir \ pip && \ - pip install -U --ignore-installed --find-links https://wheel-index.linuxserver.io/alpine/ -r requirements.txt && \ + pip install --no-cache-dir --ignore-installed --find-links https://wheel-index.linuxserver.io/alpine/ -r requirements.txt && \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \ diff --git a/README.md b/README.md index dea378b..a5b309d 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **03.04.22:** - Rebase to alpine-nginx baseimage. * **11.12.21:** - Add py3-mysqlclient for mysql/mariadb. * **14.11.21:** - Add lxml dependencies (temp fix for amd64 by force compiling lxml). * **25.07.21:** - Add libpq for postgresql. diff --git a/readme-vars.yml b/readme-vars.yml index ff981c3..e2553fd 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -39,6 +39,7 @@ app_setup_block: | # changelog changelogs: + - { date: "03.04.22:", desc: "Rebase to alpine-nginx baseimage." } - { date: "11.12.21:", desc: "Add py3-mysqlclient for mysql/mariadb." } - { date: "14.11.21:", desc: "Add lxml dependencies (temp fix for amd64 by force compiling lxml)." } - { date: "25.07.21:", desc: "Add libpq for postgresql." } diff --git a/root/defaults/default b/root/defaults/default new file mode 100644 index 0000000..11e6054 --- /dev/null +++ b/root/defaults/default @@ -0,0 +1,20 @@ +## Version 2022/04/03 - Changelog: https://github.com/linuxserver/docker-babybuddy/commits/main/root/defaults/default + +server { + listen 8000 default_server; + + server_name _; + + client_max_body_size 0; + + location / { + proxy_pass http://127.0.0.1:3000; + proxy_set_header Host $host; + proxy_redirect off; + } + + location ^~ /media/ { + root /app/babybuddy/; + } + +} \ No newline at end of file diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index f000faa..9d248ea 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -21,4 +21,4 @@ python3 manage.py migrate --noinput python3 manage.py createcachetable chown -R abc:abc \ - /config \ No newline at end of file + /config diff --git a/root/etc/services.d/babybuddy/run b/root/etc/services.d/babybuddy/run index 9dcd9ac..e923b4f 100644 --- a/root/etc/services.d/babybuddy/run +++ b/root/etc/services.d/babybuddy/run @@ -10,6 +10,6 @@ export \ SECRET_KEY="${SECRET_KEY:-`cat /config/.secretkey`}" exec \ - s6-setuidgid abc gunicorn babybuddy.wsgi -b :8000 --log-level=info \ + s6-setuidgid abc gunicorn babybuddy.wsgi -b 127.0.0.1:3000 --log-level=info \ --worker-tmp-dir=/dev/shm --log-file=- \ --workers=2 --threads=4 --worker-class=gthread From fa40dd6a4b4bb3c0fcff7e5eea9970302297c3a4 Mon Sep 17 00:00:00 2001 From: aptalca Date: Mon, 4 Apr 2022 12:47:18 -0400 Subject: [PATCH 2/3] add CSRF_TRUSTED_ORIGINS env var --- README.md | 5 ++++- readme-vars.yml | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5b309d..48ba08d 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ services: container_name: babybuddy environment: - TZ=Europe/London + - CSRF_TRUSTED_ORIGINS=http://127.0.0.1:8000,https://babybuddy.domain.com volumes: - /path/to/appdata:/config ports: @@ -92,6 +93,7 @@ services: docker run -d \ --name=babybuddy \ -e TZ=Europe/London \ + -e CSRF_TRUSTED_ORIGINS=http://127.0.0.1:8000,https://babybuddy.domain.com \ -p 8000:8000 \ -v /path/to/appdata:/config \ --restart unless-stopped \ @@ -106,6 +108,7 @@ Container images are configured using parameters passed at runtime (such as thos | :----: | --- | | `-p 8000` | the port for the web ui | | `-e TZ=Europe/London` | Specify a timezone to use EG Europe/London | +| `-e CSRF_TRUSTED_ORIGINS=http://127.0.0.1:8000,https://babybuddy.domain.com` | Add any address you'd like to access babybuddy at (comma separated, no spaces) | | `-v /config` | Contains all relevant configuration and data. | ## Environment variables from files (Docker secrets) @@ -204,7 +207,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions -* **03.04.22:** - Rebase to alpine-nginx baseimage. +* **03.04.22:** - Rebase to alpine-nginx baseimage. Add `CSRF_TRUSTED_ORIGINS` env var. * **11.12.21:** - Add py3-mysqlclient for mysql/mariadb. * **14.11.21:** - Add lxml dependencies (temp fix for amd64 by force compiling lxml). * **25.07.21:** - Add libpq for postgresql. diff --git a/readme-vars.yml b/readme-vars.yml index e2553fd..b1aa47b 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -25,6 +25,7 @@ param_ports: param_usage_include_env: true param_env_vars: - { env_var: "TZ", env_value: "Europe/London", desc: "Specify a timezone to use EG Europe/London" } + - { env_var: "CSRF_TRUSTED_ORIGINS", env_value: "http://127.0.0.1:8000,https://babybuddy.domain.com", desc: "Add any address you'd like to access babybuddy at (comma separated, no spaces)" } # optional container parameters opt_param_usage_include_env: false @@ -39,7 +40,7 @@ app_setup_block: | # changelog changelogs: - - { date: "03.04.22:", desc: "Rebase to alpine-nginx baseimage." } + - { date: "03.04.22:", desc: "Rebase to alpine-nginx baseimage. Add `CSRF_TRUSTED_ORIGINS` env var." } - { date: "11.12.21:", desc: "Add py3-mysqlclient for mysql/mariadb." } - { date: "14.11.21:", desc: "Add lxml dependencies (temp fix for amd64 by force compiling lxml)." } - { date: "25.07.21:", desc: "Add libpq for postgresql." } From 893420f0cdb5b595ace8a5d68a9a5a316d1d72b4 Mon Sep 17 00:00:00 2001 From: aptalca Date: Mon, 4 Apr 2022 12:54:10 -0400 Subject: [PATCH 3/3] let nginx serve /static/ --- root/defaults/default | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/root/defaults/default b/root/defaults/default index 11e6054..f7ecf41 100644 --- a/root/defaults/default +++ b/root/defaults/default @@ -17,4 +17,8 @@ server { root /app/babybuddy/; } + location ^~ /static/ { + root /app/babybuddy/; + } + } \ No newline at end of file