Working postgres container
This commit is contained in:
parent
b042d128fc
commit
6f77e662d5
67
compose.yml
67
compose.yml
|
@ -1,12 +1,24 @@
|
||||||
version: '3.3'
|
---
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
postgres:
|
||||||
|
image: "postgres:9.6.5"
|
||||||
|
volumes:
|
||||||
|
- "postgres:/var/lib/postgresql/data"
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: selfoss
|
||||||
|
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
|
||||||
|
POSTGRES_DB: selfoss
|
||||||
|
secrets:
|
||||||
|
- db_password
|
||||||
|
|
||||||
selfoss:
|
selfoss:
|
||||||
image: akito13/selfoss
|
image: akito13/selfoss
|
||||||
volumes:
|
volumes:
|
||||||
- selfoss:/selfoss/data
|
- selfoss:/selfoss/data
|
||||||
networks:
|
|
||||||
- proxy
|
|
||||||
deploy:
|
deploy:
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
|
@ -18,10 +30,59 @@ services:
|
||||||
- traefik.http.routers.${STACK_NAME}-https.tls=true
|
- traefik.http.routers.${STACK_NAME}-https.tls=true
|
||||||
- traefik.http.routers.${STACK_NAME}-https.tls.certresolver=${LETS_ENCRYPT_ENV}
|
- traefik.http.routers.${STACK_NAME}-https.tls.certresolver=${LETS_ENCRYPT_ENV}
|
||||||
- traefik.http.services.${STACK_NAME}.loadbalancer.server.port=8888
|
- traefik.http.services.${STACK_NAME}.loadbalancer.server.port=8888
|
||||||
|
update_config:
|
||||||
|
failure_action: rollback
|
||||||
|
order: start-first
|
||||||
|
environment:
|
||||||
|
- SELFOSS_USERNAME
|
||||||
|
- SELFOSS_PASSWORD
|
||||||
|
#- SELFOSS_PASSWORD_FILE=/run/secrets/selfoss_password
|
||||||
|
- SELFOSS_DB_TYPE
|
||||||
|
- SELFOSS_LOGGER_LEVEL
|
||||||
|
- SELFOSS_DB_HOST="postgres"
|
||||||
|
- SELFOSS_DB_NAME="selfoss"
|
||||||
|
- SELFOSS_DB_USERNAME="selfoss"
|
||||||
|
- SELFOSS_DB_PASSWORD_FILE=/run/secrets/db_password
|
||||||
|
secrets:
|
||||||
|
- db_password
|
||||||
|
#- selfoss_password
|
||||||
|
entrypoint: /docker-entrypoint.sh
|
||||||
|
#entrypoint: ['tail', '-f', '/dev/null']
|
||||||
|
configs:
|
||||||
|
- source: entrypoint_conf
|
||||||
|
target: /docker-entrypoint.sh
|
||||||
|
mode: 0555
|
||||||
|
networks:
|
||||||
|
- proxy
|
||||||
|
- internal
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
#healthcheck:
|
||||||
|
# test: ["CMD", "wget", "-f" "http://localhost:8888"]
|
||||||
|
# interval: 30s
|
||||||
|
# timeout: 10s
|
||||||
|
# retries: 10
|
||||||
|
# start_period: 1m
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
proxy:
|
proxy:
|
||||||
external: true
|
external: true
|
||||||
|
internal:
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
selfoss:
|
selfoss:
|
||||||
|
postgres:
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
db_password:
|
||||||
|
external: true
|
||||||
|
name: ${STACK_NAME}_db_password_${DB_PASSWORD_VERSION}
|
||||||
|
#selfoss_password:
|
||||||
|
# external: true
|
||||||
|
# name: ${STACK_NAME}_selfoss_password_${SELFOSS_PASSWORD_VERSION}
|
||||||
|
|
||||||
|
configs:
|
||||||
|
entrypoint_conf:
|
||||||
|
name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_CONF_VERSION}
|
||||||
|
file: entrypoint.sh.tmpl
|
||||||
|
template_driver: golang
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
configure_php() {
|
||||||
|
if ! grep -q '^clear_env = no' /etc/php7/php-fpm.d/www.conf; then
|
||||||
|
sed -i 's/;clear_env = no/clear_env = no/' /etc/php7/php-fpm.d/www.conf
|
||||||
|
fi
|
||||||
|
if ! grep -q '^clear_env = no' /etc/php7/php-fpm.conf; then
|
||||||
|
echo 'clear_env = no' >> /etc/php7/php-fpm.conf
|
||||||
|
fi
|
||||||
|
if ! grep -q 'variables_order = "EGPCS"' /etc/php7/php.ini; then
|
||||||
|
sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/g' \
|
||||||
|
/etc/php7/php.ini
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
file_env() {
|
||||||
|
local var="$1"
|
||||||
|
local fileVar="${var}_FILE"
|
||||||
|
local def="${2:-}"
|
||||||
|
|
||||||
|
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||||
|
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local val="$def"
|
||||||
|
if [ "${!var:-}" ]; then
|
||||||
|
val="${!var}"
|
||||||
|
elif [ "${!fileVar:-}" ]; then
|
||||||
|
val="$(< "${!fileVar}")"
|
||||||
|
fi
|
||||||
|
export "$var"="$val"
|
||||||
|
unset "$fileVar"
|
||||||
|
}
|
||||||
|
|
||||||
|
load_vars() {
|
||||||
|
file_env "SELFOSS_PASSWORD"
|
||||||
|
file_env "SELFOSS_DB_PASSWORD"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
configure_php
|
||||||
|
load_vars
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
|
||||||
|
run.sh
|
Reference in New Issue