One-shot install

This commit is contained in:
3wc 2020-09-09 00:52:37 +02:00
parent 2166d5a1d2
commit af10cabaf8
2 changed files with 45 additions and 6 deletions

View File

@ -1,4 +1,4 @@
version: "3.7"
version: "3.8"
services:
nextcloud:
@ -6,23 +6,32 @@ services:
depends_on:
- mariadb
secrets:
- db_root_password
- db_password
- admin_password
environment:
- MYSQL_HOST=mariadb
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_password
- DOMAIN=${DOMAIN}
- STACK_NAME=${STACK_NAME}
volumes:
- nextcloud:/var/www/html
- nextapps:/var/www/html/custom_apps:cached
- nextdata:/var/www/html/data:cached
- nextconfig:/var/www/html/config:cached
networks:
- proxy
- internal
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 10
start_period: 1m
configs:
- source: entrypoint_conf
target: /docker-entrypoint.sh
mode: 0555
user: www-data
group: www-data
deploy:
restart_policy:
condition: on-failure
@ -34,6 +43,8 @@ services:
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
#entrypoint: ["setpriv", "--reuid=www-data", "--regid=www-data", "--init-groups", "/docker-entrypoint.sh"]
entrypoint: ["tail", "-f", "/dev/null"]
mariadb:
image: "mariadb:10.5"
@ -57,9 +68,11 @@ secrets:
db_password:
external: true
name: ${STACK_NAME}_db_password_${DB_ROOT_PASSWORD_VERSION}
admin_password:
external: true
name: ${STACK_NAME}_admin_password_${ADMIN_PASSWORD_VERSION}
volumes:
nextcloud:
nextapps:
nextdata:
nextconfig:
@ -69,3 +82,9 @@ networks:
proxy:
external: true
internal:
configs:
entrypoint_conf:
name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_CONF_VERSION}
file: entrypoint.sh.tmpl
template_driver: golang

20
entrypoint.sh.tmpl Normal file
View File

@ -0,0 +1,20 @@
#!/bin/bash
set -x
SUDO="setpriv --reuid=www-data --regid=www-data --init-groups"
OCC="php /var/www/html/occ"
if ! $SUDO $OCC status | grep -q 'installed: true'; then
$SUDO $OCC --no-ansi -n maintenance:install \
--database "mysql" \
--database-name "nextcloud" \
--database-host "mariadb" \
--database-user "nextcloud" \
--database-pass "$(tr -d '\n' < /run/secrets/db_password)" \
--admin-pass "$(tr -d '\n' < /run/secrets/admin_password)"
fi
$SUDO php $OCC config:system:set trusted_domains 1 --value={{ env "DOMAIN" }}
/entrypoint.sh apache2-foreground