From 0e1c6f987bb086c1d3a9209d508ec6be8cefb821 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Sat, 29 Aug 2020 16:09:04 +0200 Subject: [PATCH] Added custom Dockerfiles for web and api services --- api/Dockerfile | 10 +++++++ api/enable_pjpeg.patch | 10 +++++++ docker-compose.yml | 26 ++++++++----------- nginx/Dockerfile | 15 +++++++++++ nginx/root/entrypoint.sh | 13 ++++++++++ .../etc/nginx/conf.d}/funkwhale.template | 0 .../{ => root/etc/nginx}/funkwhale_proxy.conf | 0 7 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 api/Dockerfile create mode 100644 api/enable_pjpeg.patch create mode 100644 nginx/Dockerfile create mode 100755 nginx/root/entrypoint.sh rename nginx/{ => root/etc/nginx/conf.d}/funkwhale.template (100%) rename nginx/{ => root/etc/nginx}/funkwhale_proxy.conf (100%) diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..fbc1323 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,10 @@ +ARG IMAGE +ARG TAG + +FROM ${IMAGE}:${TAG} + +LABEL maintainer="Meliurwen " + +COPY enable_pjpeg.patch enable_pjpeg.patch + +RUN patch -p1 < enable_pjpeg.patch diff --git a/api/enable_pjpeg.patch b/api/enable_pjpeg.patch new file mode 100644 index 0000000..dc190e3 --- /dev/null +++ b/api/enable_pjpeg.patch @@ -0,0 +1,10 @@ +--- api/config/settings/common.py.original 2020-08-29 12:29:47.397299670 +0200 ++++ api/config/settings/common.py 2020-08-29 12:38:28.702664515 +0200 +@@ -1228,6 +1228,7 @@ + VERSATILEIMAGEFIELD_SETTINGS = { + "create_images_on_demand": False, + "jpeg_resize_quality": env.int("THUMBNAIL_JPEG_RESIZE_QUALITY", default=95), ++ "progressive_jpeg": True, + } + RSA_KEY_SIZE = 2048 + # for performance gain in tests, since we don't need to actually create the diff --git a/docker-compose.yml b/docker-compose.yml index 903a985..77f6eda 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,7 +56,11 @@ services: command: celery -A funkwhale_api.taskapp beat --pidfile= -l INFO api: - image: funkwhale/funkwhale:${FUNKWHALE_VERSION:-latest} + build: + context: api/. + args: + - IMAGE=funkwhale/funkwhale + - TAG=${FUNKWHALE_VERSION:-latest} container_name: ${AP_CONTAINER_NAME:-funkwhale-api} restart: ${AP_RESTART:-unless-stopped} networks: @@ -78,8 +82,12 @@ services: environment: - FUNKWHALE_HOSTNAME=${FUNKWHALE_HOSTNAME} - nginx: - image: ${WB_IMG:-nginx}:${WB_TAG:-latest} + web: + build: + context: nginx/. + args: + - IMAGE=${WB_IMG:-nginx} + - TAG=${WB_TAG:-latest} container_name: ${WB_CONTAINER_NAME:-funkwhale-web} restart: ${WB_RESTART:-unless-stopped} networks: @@ -88,8 +96,6 @@ services: depends_on: - api volumes: - - "./nginx/funkwhale.template:/etc/nginx/conf.d/funkwhale.template:ro" - - "./nginx/funkwhale_proxy.conf:/etc/nginx/funkwhale_proxy.conf:ro" - "${HOST_MUSIC_DIRECTORY_PATH}:/srv/wwww/music:ro" - "${HOST_MEDIA_ROOT}:/srv/wwww/media:ro" - "${HOST_STATIC_ROOT}:/srv/wwww/static:ro" @@ -100,16 +106,6 @@ services: - nginx.env environment: - FUNKWHALE_HOSTNAME=${FUNKWHALE_HOSTNAME} - - MEDIA_ROOT=/srv/wwww/media - - MUSIC_DIRECTORY_PATH=/srv/wwww/music - - STATIC_ROOT=/srv/wwww/static - - FUNKWHALE_FRONTEND_PATH=/srv/wwww/frontend - command: > - sh -c "envsubst \"`env | awk -F = '{printf \" $$%s\", $$1}'`\" - < /etc/nginx/conf.d/funkwhale.template - > /etc/nginx/conf.d/default.conf - && cat /etc/nginx/conf.d/default.conf - && nginx -g 'daemon off;'" networks: default: diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..50635ed --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,15 @@ +ARG IMAGE +ARG TAG + +FROM ${IMAGE}:${TAG} + +LABEL maintainer="Meliurwen " + +COPY root/ / + +ENV MEDIA_ROOT=/srv/wwww/media +ENV MUSIC_DIRECTORY_PATH=/srv/wwww/music +ENV STATIC_ROOT=/srv/wwww/static +ENV FUNKWHALE_FRONTEND_PATH=/srv/wwww/frontend + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/nginx/root/entrypoint.sh b/nginx/root/entrypoint.sh new file mode 100755 index 0000000..ef6aced --- /dev/null +++ b/nginx/root/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Exit at first error +set -e + +# Fill the varibles in funkwhale.template and put the result in default.conf +envsubst "`env | awk -F = '{printf \" $$%s\", $$1}'`" < \ + /etc/nginx/conf.d/funkwhale.template > \ + /etc/nginx/conf.d/default.conf + +cat /etc/nginx/conf.d/default.conf + +nginx -g 'daemon off;' diff --git a/nginx/funkwhale.template b/nginx/root/etc/nginx/conf.d/funkwhale.template similarity index 100% rename from nginx/funkwhale.template rename to nginx/root/etc/nginx/conf.d/funkwhale.template diff --git a/nginx/funkwhale_proxy.conf b/nginx/root/etc/nginx/funkwhale_proxy.conf similarity index 100% rename from nginx/funkwhale_proxy.conf rename to nginx/root/etc/nginx/funkwhale_proxy.conf