Docker: add service 'memcached'

Additionally, setup memcached for php-fpm.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-08-08 18:35:49 -07:00
parent ae0f69a5e4
commit 35851d5533
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
6 changed files with 24 additions and 1 deletions

View file

@ -28,6 +28,10 @@ enable-maintenance = 0
localedir = YOUR_AUR_ROOT/web/locale
; In production, salt_rounds should be higher; suggested: 12.
salt_rounds = 4
cache = none
; In docker, the memcached host is available. On a user's system,
; this should be set to localhost (most likely).
memcache_servers = memcached:11211
[notifications]
; For development/testing, use /usr/bin/sendmail

View file

@ -29,6 +29,13 @@ services:
volumes:
- ./cache:/cache
memcached:
image: aurweb:latest
init: true
command: /docker/scripts/run-memcached.sh
healthcheck:
test: "bash /docker/health/memcached.sh"
mariadb:
image: aurweb:latest
init: true
@ -136,6 +143,8 @@ services:
condition: service_healthy
mariadb:
condition: service_healthy
memcached:
condition: service_healthy
volumes:
- mariadb_run:/var/run/mysqld # Bind socket in this volume.
- mariadb_data:/var/lib/mysql

2
docker/health/memcached.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
exec pgrep memcached

View file

@ -7,6 +7,9 @@ bash $dir/test-mysql-entrypoint.sh
sed -ri "s;^(aur_location) = .+;\1 = https://localhost:8443;" conf/config
sed -ri 's/^(name) = .+/\1 = aurweb/' conf/config
# Enable memcached.
sed -ri 's/^(cache) = .+$/\1 = memcache/' conf/config
sed -ri "s|^(git_clone_uri_anon) = .+|\1 = https://localhost:8443/%s.git|" conf/config.defaults
sed -ri "s|^(git_clone_uri_priv) = .+|\1 = ssh://aur@localhost:2222/%s.git|" conf/config.defaults
@ -21,6 +24,9 @@ sed -ri 's|^;?(access\.log) = .*$|\1 = /proc/self/fd/2|g' \
sed -ri 's/^;?(extension=pdo_mysql)/\1/' /etc/php/php.ini
sed -ri 's/^;?(open_basedir).*$/\1 = \//' /etc/php/php.ini
# Use the sqlite3 extension line for memcached.
sed -ri 's/^;(extension)=sqlite3$/\1=memcached/' /etc/php/php.ini
python -m aurweb.initdb 2>/dev/null || /bin/true
exec "$@"

View file

@ -14,6 +14,6 @@ pacman -Syu --noconfirm --noprogressbar \
python-pytest-asyncio python-coverage hypercorn python-bcrypt \
python-email-validator openssh python-lxml mariadb mariadb-libs \
python-isort flake8 cgit uwsgi uwsgi-plugin-cgi php php-fpm \
python-asgiref uvicorn python-feedgen
python-asgiref uvicorn python-feedgen memcached php-memcached
exec "$@"

View file

@ -0,0 +1,2 @@
#!/bin/bash
exec /usr/bin/memcached -u memcached -m 64 -c 1024 -l 0.0.0.0