From 69de6b0967654dabdd94d5103848ae80642443cb Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 1 Feb 2024 11:33:53 +0100 Subject: [PATCH] Update to 0.4.5 and replace supervisor with minit --- bounca.nomad.hcl | 19 +++++++++++++++++++ example/bounca.nomad.hcl | 15 ++++++++++++++- example/images/bounca/Dockerfile | 6 +++--- .../images/bounca/root/etc/minit.d/bounca.yml | 16 ++++++++++++++++ .../images/bounca/root/etc/supervisord.conf | 8 -------- .../etc/supervisord.d/bounca-gunicorn.ini | 10 ---------- .../root/etc/supervisord.d/bounca-nginx.ini | 10 ---------- .../etc/supervisord.d/bounca-pub-export.ini | 10 ---------- .../bounca/root/etc/supervisord.d/bounca.ini | 2 -- .../images/bounca/root/usr/local/bin/bounca | 2 +- images/bounca/Dockerfile | 6 +++--- images/bounca/root/etc/minit.d/bounca.yml | 16 ++++++++++++++++ images/bounca/root/etc/supervisord.conf | 8 -------- .../etc/supervisord.d/bounca-gunicorn.ini | 10 ---------- .../root/etc/supervisord.d/bounca-nginx.ini | 10 ---------- .../etc/supervisord.d/bounca-pub-export.ini | 10 ---------- .../bounca/root/etc/supervisord.d/bounca.ini | 2 -- images/bounca/root/usr/local/bin/bounca | 2 +- variables.yml | 3 +++ 19 files changed, 76 insertions(+), 89 deletions(-) create mode 100644 example/images/bounca/root/etc/minit.d/bounca.yml delete mode 100644 example/images/bounca/root/etc/supervisord.conf delete mode 100644 example/images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini delete mode 100644 example/images/bounca/root/etc/supervisord.d/bounca-nginx.ini delete mode 100644 example/images/bounca/root/etc/supervisord.d/bounca-pub-export.ini delete mode 100644 example/images/bounca/root/etc/supervisord.d/bounca.ini create mode 100644 images/bounca/root/etc/minit.d/bounca.yml delete mode 100644 images/bounca/root/etc/supervisord.conf delete mode 100644 images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini delete mode 100644 images/bounca/root/etc/supervisord.d/bounca-nginx.ini delete mode 100644 images/bounca/root/etc/supervisord.d/bounca-pub-export.ini delete mode 100644 images/bounca/root/etc/supervisord.d/bounca.ini diff --git a/bounca.nomad.hcl b/bounca.nomad.hcl index af18392..ddf6d62 100644 --- a/bounca.nomad.hcl +++ b/bounca.nomad.hcl @@ -70,6 +70,8 @@ BOUNCA_DB_PORT=[[ $c.postgres.port ]] [[- end ]] _EOT destination = "secrets/.db.env" + env = true + perms = 400 } [[ template "common/resources.tpl" $c.resources ]] @@ -100,6 +102,23 @@ _EOT [[ template "common/file_env.tpl" $c.env ]] + template { + data =<<_EOT +[[- if ne $c.postgres.pooler.engine "none" ]] +BOUNCA_DB_USER=[[ .instance ]] +BOUNCA_DB_PASSWORD={{ env "NOMAD_ALLOC_ID" }} +BOUNCA_DB_PORT=[[ $c.postgres.pooler.port ]] +[[- else ]] +BOUNCA_DB_USER=[[ $c.postgres.user ]] +BOUNCA_DB_PASSWORD=[[ $c.postgres.password ]] +BOUNCA_DB_PORT=[[ $c.postgres.port ]] +[[- end ]] +_EOT + destination = "secrets/.db.env" + env = true + perms = 400 + } + resources { cpu = 10 memory = 10 diff --git a/example/bounca.nomad.hcl b/example/bounca.nomad.hcl index 8ca3d0f..a12a6b0 100644 --- a/example/bounca.nomad.hcl +++ b/example/bounca.nomad.hcl @@ -72,7 +72,7 @@ job "bounca" { user = 1053 config { - image = "danielberteaud/wait-for:24.1-1" + image = "danielberteaud/wait-for:24.2-1" readonly_rootfs = true pids_limit = 20 } @@ -194,6 +194,8 @@ BOUNCA_DB_PASSWORD={{ with secret "//database/creds/bounca" }}{{ .Data.password BOUNCA_DB_PORT=5432 _EOT destination = "secrets/.db.env" + env = true + perms = 400 } @@ -254,6 +256,17 @@ _EOT } + template { + data = <<_EOT +BOUNCA_DB_USER={{ with secret "//database/creds/bounca" }}{{ .Data.username }}{{ end }} +BOUNCA_DB_PASSWORD={{ with secret "//database/creds/bounca" }}{{ .Data.password }}{{ end }} +BOUNCA_DB_PORT=5432 +_EOT + destination = "secrets/.db.env" + env = true + perms = 400 + } + resources { cpu = 10 memory = 10 diff --git a/example/images/bounca/Dockerfile b/example/images/bounca/Dockerfile index c96dd41..0817a14 100644 --- a/example/images/bounca/Dockerfile +++ b/example/images/bounca/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.11-alpine AS builder -ARG BOUNCA_VERSION=0.4.4 +ARG BOUNCA_VERSION=0.4.5 workdir /opt RUN set -euxo pipefail &&\ @@ -72,9 +72,9 @@ RUN set -euxo pipefail &&\ gettext \ openssl \ nginx \ - supervisor \ - postgresql15-client + postgresql16-client +COPY --from=danielberteaud/alpine:24.2-1 /usr/local/bin/minit /usr/local/bin/minit COPY root/ / WORKDIR /opt/bounca diff --git a/example/images/bounca/root/etc/minit.d/bounca.yml b/example/images/bounca/root/etc/minit.d/bounca.yml new file mode 100644 index 0000000..be60d69 --- /dev/null +++ b/example/images/bounca/root/etc/minit.d/bounca.yml @@ -0,0 +1,16 @@ +--- +kind: daemon +name: gunicorn +command: ["sh", "-c", "source /opt/bounca/venv/bin/activate && gunicorn --bind=unix:${BOUNCA_UNIX_SOCKET} --threads=4 --max-requests=10000 bounca.wsgi:applicatio"] + +--- +kind: daemon +name: nginx +command: ["nginx", "-c", "/tmp/nginx.conf"] + +--- +kind: cron +name: pu-export +command: ["/usr/local/bin/bounca-pub-export"] +cron: '*/15 * * * *' + diff --git a/example/images/bounca/root/etc/supervisord.conf b/example/images/bounca/root/etc/supervisord.conf deleted file mode 100644 index c94ef46..0000000 --- a/example/images/bounca/root/etc/supervisord.conf +++ /dev/null @@ -1,8 +0,0 @@ -[supervisord] -pidfile=/tmp/supervisord.pi -nodaemon=true -logfile=/dev/stdout -logfile_maxbytes=0 - -[include] -files = supervisord.d/*.ini diff --git a/example/images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini b/example/images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini deleted file mode 100644 index aaabdf9..0000000 --- a/example/images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini +++ /dev/null @@ -1,10 +0,0 @@ -[program:gunicorn] -command=sh -c "source /opt/bounca/venv/bin/activate && gunicorn --bind=unix:${BOUNCA_UNIX_SOCKET} --threads=4 --max-requests=10000 bounca.wsgi:application" -stdout_logfile=/proc/self/fd/1 -stdout_logfile_backups=0 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/self/fd/2 -stderr_logfile_backups=0 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/example/images/bounca/root/etc/supervisord.d/bounca-nginx.ini b/example/images/bounca/root/etc/supervisord.d/bounca-nginx.ini deleted file mode 100644 index b13d198..0000000 --- a/example/images/bounca/root/etc/supervisord.d/bounca-nginx.ini +++ /dev/null @@ -1,10 +0,0 @@ -[program:nginx] -command=/usr/sbin/nginx -c /tmp/nginx.conf -stdout_logfile=/proc/self/fd/1 -stdout_logfile_backups=0 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/self/fd/2 -stderr_logfile_backups=0 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/example/images/bounca/root/etc/supervisord.d/bounca-pub-export.ini b/example/images/bounca/root/etc/supervisord.d/bounca-pub-export.ini deleted file mode 100644 index 98fd8ab..0000000 --- a/example/images/bounca/root/etc/supervisord.d/bounca-pub-export.ini +++ /dev/null @@ -1,10 +0,0 @@ -[program:pub-export] -command=/usr/local/bin/bounca-pub-export 300 -stdout_logfile=/proc/self/fd/1 -stdout_logfile_backups=0 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/self/fd/2 -stderr_logfile_backups=0 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/example/images/bounca/root/etc/supervisord.d/bounca.ini b/example/images/bounca/root/etc/supervisord.d/bounca.ini deleted file mode 100644 index da3725a..0000000 --- a/example/images/bounca/root/etc/supervisord.d/bounca.ini +++ /dev/null @@ -1,2 +0,0 @@ -[group:bounca] -programs=gunicorn,nginx,pub-export diff --git a/example/images/bounca/root/usr/local/bin/bounca b/example/images/bounca/root/usr/local/bin/bounca index ee0e3d3..66e7c7d 100755 --- a/example/images/bounca/root/usr/local/bin/bounca +++ b/example/images/bounca/root/usr/local/bin/bounca @@ -5,7 +5,7 @@ set -euo pipefail source /opt/bounca/venv/bin/activate if [ "${BOUNCA_MODE}" = "all-in-one" ]; then - exec supervisor -c /etc/supervisord.conf -n + exec minit elif [ "${BOUNCA_MODE}" = "server" ]; then exec gunicorn \ --bind=unix:/alloc/data/bounca.sock \ diff --git a/images/bounca/Dockerfile b/images/bounca/Dockerfile index da913cf..5b77c23 100644 --- a/images/bounca/Dockerfile +++ b/images/bounca/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.11-alpine AS builder -ARG BOUNCA_VERSION=0.4.4 +ARG BOUNCA_VERSION=[[ .bounca.version ]] workdir /opt RUN set -euxo pipefail &&\ @@ -72,9 +72,9 @@ RUN set -euxo pipefail &&\ gettext \ openssl \ nginx \ - supervisor \ - postgresql15-client + postgresql16-client +COPY --from=[[ .docker.repo ]][[ .docker.base_images.alpine.image ]] /usr/local/bin/minit /usr/local/bin/minit COPY root/ / WORKDIR /opt/bounca diff --git a/images/bounca/root/etc/minit.d/bounca.yml b/images/bounca/root/etc/minit.d/bounca.yml new file mode 100644 index 0000000..be60d69 --- /dev/null +++ b/images/bounca/root/etc/minit.d/bounca.yml @@ -0,0 +1,16 @@ +--- +kind: daemon +name: gunicorn +command: ["sh", "-c", "source /opt/bounca/venv/bin/activate && gunicorn --bind=unix:${BOUNCA_UNIX_SOCKET} --threads=4 --max-requests=10000 bounca.wsgi:applicatio"] + +--- +kind: daemon +name: nginx +command: ["nginx", "-c", "/tmp/nginx.conf"] + +--- +kind: cron +name: pu-export +command: ["/usr/local/bin/bounca-pub-export"] +cron: '*/15 * * * *' + diff --git a/images/bounca/root/etc/supervisord.conf b/images/bounca/root/etc/supervisord.conf deleted file mode 100644 index c94ef46..0000000 --- a/images/bounca/root/etc/supervisord.conf +++ /dev/null @@ -1,8 +0,0 @@ -[supervisord] -pidfile=/tmp/supervisord.pi -nodaemon=true -logfile=/dev/stdout -logfile_maxbytes=0 - -[include] -files = supervisord.d/*.ini diff --git a/images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini b/images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini deleted file mode 100644 index aaabdf9..0000000 --- a/images/bounca/root/etc/supervisord.d/bounca-gunicorn.ini +++ /dev/null @@ -1,10 +0,0 @@ -[program:gunicorn] -command=sh -c "source /opt/bounca/venv/bin/activate && gunicorn --bind=unix:${BOUNCA_UNIX_SOCKET} --threads=4 --max-requests=10000 bounca.wsgi:application" -stdout_logfile=/proc/self/fd/1 -stdout_logfile_backups=0 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/self/fd/2 -stderr_logfile_backups=0 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/images/bounca/root/etc/supervisord.d/bounca-nginx.ini b/images/bounca/root/etc/supervisord.d/bounca-nginx.ini deleted file mode 100644 index b13d198..0000000 --- a/images/bounca/root/etc/supervisord.d/bounca-nginx.ini +++ /dev/null @@ -1,10 +0,0 @@ -[program:nginx] -command=/usr/sbin/nginx -c /tmp/nginx.conf -stdout_logfile=/proc/self/fd/1 -stdout_logfile_backups=0 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/self/fd/2 -stderr_logfile_backups=0 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/images/bounca/root/etc/supervisord.d/bounca-pub-export.ini b/images/bounca/root/etc/supervisord.d/bounca-pub-export.ini deleted file mode 100644 index 98fd8ab..0000000 --- a/images/bounca/root/etc/supervisord.d/bounca-pub-export.ini +++ /dev/null @@ -1,10 +0,0 @@ -[program:pub-export] -command=/usr/local/bin/bounca-pub-export 300 -stdout_logfile=/proc/self/fd/1 -stdout_logfile_backups=0 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/self/fd/2 -stderr_logfile_backups=0 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/images/bounca/root/etc/supervisord.d/bounca.ini b/images/bounca/root/etc/supervisord.d/bounca.ini deleted file mode 100644 index da3725a..0000000 --- a/images/bounca/root/etc/supervisord.d/bounca.ini +++ /dev/null @@ -1,2 +0,0 @@ -[group:bounca] -programs=gunicorn,nginx,pub-export diff --git a/images/bounca/root/usr/local/bin/bounca b/images/bounca/root/usr/local/bin/bounca index ee0e3d3..66e7c7d 100755 --- a/images/bounca/root/usr/local/bin/bounca +++ b/images/bounca/root/usr/local/bin/bounca @@ -5,7 +5,7 @@ set -euo pipefail source /opt/bounca/venv/bin/activate if [ "${BOUNCA_MODE}" = "all-in-one" ]; then - exec supervisor -c /etc/supervisord.conf -n + exec minit elif [ "${BOUNCA_MODE}" = "server" ]; then exec gunicorn \ --bind=unix:/alloc/data/bounca.sock \ diff --git a/variables.yml b/variables.yml index ee215be..59387a4 100644 --- a/variables.yml +++ b/variables.yml @@ -5,6 +5,9 @@ instance: bounca bounca: + # Version of BounCA + version: 0.4.5 + # The image to use image: danielberteaud/bounca:latest