change(docker): use ./data instead of ./cache

For the `git` service, ./data is always used to provide an
optional overriding of ssh host keys. In aur-dev production
containers, most services which use the data mount use an
internal Docker `data` volume instead.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-11-20 20:05:04 -08:00
parent 604901fe74
commit d4d9f50b8f
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
10 changed files with 56 additions and 57 deletions

View file

@ -3,7 +3,7 @@ version: "3.8"
services: services:
ca: ca:
volumes: volumes:
- cache:/cache - data:/data
memcached: memcached:
restart: always restart: always
@ -23,13 +23,12 @@ services:
volumes: volumes:
- ${GIT_DATA_DIR}:/aurweb/aur.git - ${GIT_DATA_DIR}:/aurweb/aur.git
- ./data:/aurweb/data - ./data:/aurweb/data
- cache:/cache
smartgit: smartgit:
restart: always restart: always
volumes: volumes:
- ${GIT_DATA_DIR}:/aurweb/aur.git - ${GIT_DATA_DIR}:/aurweb/aur.git
- cache:/cache - data:/data
- smartgit_run:/var/run/smartgit - smartgit_run:/var/run/smartgit
cgit-php: cgit-php:
@ -48,7 +47,7 @@ services:
- AURWEB_PHP_PREFIX=${AURWEB_PHP_PREFIX} - AURWEB_PHP_PREFIX=${AURWEB_PHP_PREFIX}
- AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX} - AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX}
volumes: volumes:
- cache:/cache - data:/data
fastapi: fastapi:
restart: always restart: always
@ -60,13 +59,13 @@ services:
- AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX} - AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX}
- PROMETHEUS_MULTIPROC_DIR=/tmp_prometheus - PROMETHEUS_MULTIPROC_DIR=/tmp_prometheus
volumes: volumes:
- cache:/cache - data:/data
nginx: nginx:
restart: always restart: always
volumes: volumes:
- ${GIT_DATA_DIR}:/aurweb/aur.git - ${GIT_DATA_DIR}:/aurweb/aur.git
- cache:/cache - data:/data
- logs:/var/log/nginx - logs:/var/log/nginx
- smartgit_run:/var/run/smartgit - smartgit_run:/var/run/smartgit
@ -75,5 +74,5 @@ volumes:
mariadb_data: {} # Share /var/lib/mysql mariadb_data: {} # Share /var/lib/mysql
git_data: {} # Share aurweb/aur.git git_data: {} # Share aurweb/aur.git
smartgit_run: {} smartgit_run: {}
cache: {} data: {}
logs: {} logs: {}

View file

@ -8,17 +8,17 @@ services:
ca: ca:
volumes: volumes:
- ./cache:/cache - ./data:/data
git: git:
volumes: volumes:
- git_data:/aurweb/aur.git - git_data:/aurweb/aur.git
- ./cache:/cache - ./data:/aurweb/data
smartgit: smartgit:
volumes: volumes:
- git_data:/aurweb/aur.git - git_data:/aurweb/aur.git
- ./cache:/cache - ./data:/data
- smartgit_run:/var/run/smartgit - smartgit_run:/var/run/smartgit
depends_on: depends_on:
mariadb: mariadb:
@ -26,7 +26,7 @@ services:
php-fpm: php-fpm:
volumes: volumes:
- ./cache:/cache - ./data:/data
- ./aurweb:/aurweb/aurweb - ./aurweb:/aurweb/aurweb
- ./migrations:/aurweb/migrations - ./migrations:/aurweb/migrations
- ./test:/aurweb/test - ./test:/aurweb/test
@ -37,7 +37,7 @@ services:
fastapi: fastapi:
volumes: volumes:
- ./cache:/cache - ./data:/data
- ./aurweb:/aurweb/aurweb - ./aurweb:/aurweb/aurweb
- ./migrations:/aurweb/migrations - ./migrations:/aurweb/migrations
- ./test:/aurweb/test - ./test:/aurweb/test
@ -49,7 +49,7 @@ services:
nginx: nginx:
volumes: volumes:
- git_data:/aurweb/aur.git - git_data:/aurweb/aur.git
- ./cache:/cache - ./data:/data
- ./logs:/var/log/nginx - ./logs:/var/log/nginx
- ./web/html:/aurweb/web/html - ./web/html:/aurweb/web/html
- ./web/template:/aurweb/web/template - ./web/template:/aurweb/web/template

View file

@ -276,7 +276,7 @@ services:
mariadb_test: mariadb_test:
condition: service_healthy condition: service_healthy
volumes: volumes:
- ./cache:/cache - ./data:/data
- ./aurweb:/aurweb/aurweb - ./aurweb:/aurweb/aurweb
- ./migrations:/aurweb/migrations - ./migrations:/aurweb/migrations
- ./test:/aurweb/test - ./test:/aurweb/test
@ -304,7 +304,7 @@ services:
- /tmp - /tmp
volumes: volumes:
- mariadb_test_run:/var/run/mysqld - mariadb_test_run:/var/run/mysqld
- ./cache:/cache - ./data:/data
- ./aurweb:/aurweb/aurweb - ./aurweb:/aurweb/aurweb
- ./migrations:/aurweb/migrations - ./migrations:/aurweb/migrations
- ./test:/aurweb/test - ./test:/aurweb/test
@ -330,7 +330,7 @@ services:
condition: service_healthy condition: service_healthy
volumes: volumes:
- mariadb_test_run:/var/run/mysqld - mariadb_test_run:/var/run/mysqld
- ./cache:/cache - ./data:/data
- ./aurweb:/aurweb/aurweb - ./aurweb:/aurweb/aurweb
- ./migrations:/aurweb/migrations - ./migrations:/aurweb/migrations
- ./test:/aurweb/test - ./test:/aurweb/test

View file

@ -1,58 +1,58 @@
#!/bin/bash #!/bin/bash
set -eou pipefail set -eou pipefail
if [ -f /cache/ca.root.pem ]; then if [ -f /data/ca.root.pem ]; then
echo "Already have certs, skipping." echo "Already have certs, skipping."
exit 0 exit 0
fi fi
# Generate a new 2048-bit RSA key for the Root CA. # Generate a new 2048-bit RSA key for the Root CA.
openssl genrsa -des3 -out /cache/ca.key -passout pass:devca 2048 openssl genrsa -des3 -out /data/ca.key -passout pass:devca 2048
# Request and self-sign a new Root CA certificate, using # Request and self-sign a new Root CA certificate, using
# the RSA key. Output Root CA PEM-format certificate and key: # the RSA key. Output Root CA PEM-format certificate and key:
# /cache/ca.root.pem and /cache/ca.key.pem # /data/ca.root.pem and /data/ca.key.pem
openssl req -x509 -new -nodes -sha256 -days 1825 \ openssl req -x509 -new -nodes -sha256 -days 1825 \
-passin pass:devca \ -passin pass:devca \
-subj "/C=US/ST=California/L=Authority/O=aurweb/CN=localhost" \ -subj "/C=US/ST=California/L=Authority/O=aurweb/CN=localhost" \
-in /cache/ca.key -out /cache/ca.root.pem -keyout /cache/ca.key.pem -in /data/ca.key -out /data/ca.root.pem -keyout /data/ca.key.pem
# Generate a new 2048-bit RSA key for a localhost server. # Generate a new 2048-bit RSA key for a localhost server.
openssl genrsa -out /cache/localhost.key 2048 openssl genrsa -out /data/localhost.key 2048
# Generate a Certificate Signing Request (CSR) for the localhost server # Generate a Certificate Signing Request (CSR) for the localhost server
# using the RSA key we generated above. # using the RSA key we generated above.
openssl req -new -key /cache/localhost.key -passout pass:devca \ openssl req -new -key /data/localhost.key -passout pass:devca \
-subj "/C=US/ST=California/L=Server/O=aurweb/CN=localhost" \ -subj "/C=US/ST=California/L=Server/O=aurweb/CN=localhost" \
-out /cache/localhost.csr -out /data/localhost.csr
# Get our CSR signed by our Root CA PEM-formatted certificate and key # Get our CSR signed by our Root CA PEM-formatted certificate and key
# to produce a fresh /cache/localhost.cert.pem PEM-formatted certificate. # to produce a fresh /data/localhost.cert.pem PEM-formatted certificate.
openssl x509 -req -in /cache/localhost.csr \ openssl x509 -req -in /data/localhost.csr \
-CA /cache/ca.root.pem -CAkey /cache/ca.key.pem \ -CA /data/ca.root.pem -CAkey /data/ca.key.pem \
-CAcreateserial \ -CAcreateserial \
-out /cache/localhost.cert.pem \ -out /data/localhost.cert.pem \
-days 825 -sha256 \ -days 825 -sha256 \
-passin pass:devca \ -passin pass:devca \
-extfile /docker/localhost.ext -extfile /docker/localhost.ext
# Convert RSA key to a PEM-formatted key: /cache/localhost.key.pem # Convert RSA key to a PEM-formatted key: /data/localhost.key.pem
openssl rsa -in /cache/localhost.key -text > /cache/localhost.key.pem openssl rsa -in /data/localhost.key -text > /data/localhost.key.pem
# At the end here, our notable certificates and keys are: # At the end here, our notable certificates and keys are:
# - /cache/ca.root.pem # - /data/ca.root.pem
# - /cache/ca.key.pem # - /data/ca.key.pem
# - /cache/localhost.key.pem # - /data/localhost.key.pem
# - /cache/localhost.cert.pem # - /data/localhost.cert.pem
# #
# When running a server which uses the localhost certificate, a chain # When running a server which uses the localhost certificate, a chain
# should be used, starting with localhost.cert.pem: # should be used, starting with localhost.cert.pem:
# - cat /cache/localhost.cert.pem /cache/ca.root.pem > localhost.chain.pem # - cat /data/localhost.cert.pem /data/ca.root.pem > localhost.chain.pem
# #
# The Root CA (ca.root.pem) should be imported into browsers or # The Root CA (ca.root.pem) should be imported into browsers or
# ca-certificates on machines wishing to verify localhost. # ca-certificates on machines wishing to verify localhost.
# #
chmod 666 /cache/* chmod 666 /data/*
exec "$@" exec "$@"

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -eou pipefail set -eou pipefail
mkdir -p /var/cache/cgit mkdir -p /var/data/cgit
cp -vf conf/cgitrc.proto /etc/cgitrc cp -vf conf/cgitrc.proto /etc/cgitrc
sed -ri "s|clone-prefix=.*|clone-prefix=${CGIT_CLONE_PREFIX}|" /etc/cgitrc sed -ri "s|clone-prefix=.*|clone-prefix=${CGIT_CLONE_PREFIX}|" /etc/cgitrc

View file

@ -5,8 +5,8 @@ set -eou pipefail
# user customization of the certificates that FastAPI uses. # user customization of the certificates that FastAPI uses.
# Otherwise, fallback to localhost.{cert,key}.pem, generated by `ca`. # Otherwise, fallback to localhost.{cert,key}.pem, generated by `ca`.
CERT=/cache/production.cert.pem CERT=/data/production.cert.pem
KEY=/cache/production.key.pem KEY=/data/production.key.pem
DEST_CERT=/etc/ssl/certs/web.cert.pem DEST_CERT=/etc/ssl/certs/web.cert.pem
DEST_KEY=/etc/ssl/private/web.key.pem DEST_KEY=/etc/ssl/private/web.key.pem
@ -15,8 +15,8 @@ if [ -f "$CERT" ]; then
cp -vf "$CERT" "$DEST_CERT" cp -vf "$CERT" "$DEST_CERT"
cp -vf "$KEY" "$DEST_KEY" cp -vf "$KEY" "$DEST_KEY"
else else
cat /cache/localhost.cert.pem /cache/ca.root.pem > "$DEST_CERT" cat /data/localhost.cert.pem /data/ca.root.pem > "$DEST_CERT"
cp -vf /cache/localhost.key.pem "$DEST_KEY" cp -vf /data/localhost.key.pem "$DEST_KEY"
fi fi
cp -vf /docker/config/nginx.conf /etc/nginx/nginx.conf cp -vf /docker/config/nginx.conf /etc/nginx/nginx.conf

View file

@ -1,15 +1,15 @@
#!/bin/bash #!/bin/bash
CERT=/cache/localhost.cert.pem CERT=/data/localhost.cert.pem
KEY=/cache/localhost.key.pem KEY=/data/localhost.key.pem
# If production.{cert,key}.pem exists, prefer them. This allows # If production.{cert,key}.pem exists, prefer them. This allows
# user customization of the certificates that FastAPI uses. # user customization of the certificates that FastAPI uses.
if [ -f /cache/production.cert.pem ]; then if [ -f /data/production.cert.pem ]; then
CERT=/cache/production.cert.pem CERT=/data/production.cert.pem
fi fi
if [ -f /cache/production.key.pem ]; then if [ -f /data/production.key.pem ]; then
KEY=/cache/production.key.pem KEY=/data/production.key.pem
fi fi
# By default, set FASTAPI_WORKERS to 2. In production, this should # By default, set FASTAPI_WORKERS to 2. In production, this should

View file

@ -8,7 +8,7 @@ echo " (cgit) : https://localhost:8444/cgit/"
echo " - PHP : https://localhost:8443/" echo " - PHP : https://localhost:8443/"
echo " (cgit) : https://localhost:8443/cgit/" echo " (cgit) : https://localhost:8443/cgit/"
echo echo
echo " Note: Copy root CA (./cache/ca.root.pem) to ca-certificates or browser." echo " Note: Copy root CA (./data/ca.root.pem) to ca-certificates or browser."
echo echo
echo " Thanks for using aurweb!" echo " Thanks for using aurweb!"
echo echo

View file

@ -32,10 +32,10 @@ pytest
if [ $COVERAGE -eq 1 ]; then if [ $COVERAGE -eq 1 ]; then
make -C test coverage make -C test coverage
# /cache is mounted as a volume. Copy coverage into it. # /data is mounted as a volume. Copy coverage into it.
# Users can then sanitize the coverage locally in their # Users can then sanitize the coverage locally in their
# aurweb root directory: ./util/fix-coverage ./cache/.coverage # aurweb root directory: ./util/fix-coverage ./data/.coverage
rm -f /cache/.coverage rm -f /data/.coverage
cp -v .coverage /cache/.coverage cp -v .coverage /data/.coverage
chmod 666 /cache/.coverage chmod 666 /data/.coverage
fi fi

View file

@ -14,12 +14,12 @@ bash $dir/run-pytests.sh --no-coverage
make -C test coverage make -C test coverage
# /cache is mounted as a volume. Copy coverage into it. # /data is mounted as a volume. Copy coverage into it.
# Users can then sanitize the coverage locally in their # Users can then sanitize the coverage locally in their
# aurweb root directory: ./util/fix-coverage ./cache/.coverage # aurweb root directory: ./util/fix-coverage ./data/.coverage
rm -f /cache/.coverage rm -f /data/.coverage
cp -v .coverage /cache/.coverage cp -v .coverage /data/.coverage
chmod 666 /cache/.coverage chmod 666 /data/.coverage
# Run flake8 and isort checks. # Run flake8 and isort checks.
for dir in aurweb test migrations; do for dir in aurweb test migrations; do