Created
May 23, 2022 05:32
-
-
Save suderman/309777c9cb22ae0478368baff29c32e9 to your computer and use it in GitHub Desktop.
wallabag docker stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
# https://hub.docker.com/r/wallabag/wallabag | |
web: | |
image: "wallabag/wallabag" | |
deploy: | |
mode: replicated | |
replicas: 1 | |
labels: | |
traefik.enable: "true" | |
traefik.docker.network: "traefik" | |
traefik.http.routers.wallabag.entrypoints: "websecure" | |
traefik.http.routers.wallabag.rule: "Host(`wallabag.${HOMELAB_DOMAIN}`)" | |
traefik.http.routers.wallabag.tls.certresolver: "resolver-dns" | |
traefik.http.services.wallabag.loadbalancer.server.port: "80" | |
logging: | |
options: | |
max-size: 10m | |
environment: | |
POSTGRES_USER: admin | |
POSTGRES_PASSWORD: ${HOMELAB_SECRET} | |
POPULATE_DATABASE: "false" | |
SYMFONY__ENV__DATABASE_DRIVER: pdo_pgsql | |
SYMFONY__ENV__DATABASE_HOST: db | |
SYMFONY__ENV__DATABASE_PORT: 5432 | |
SYMFONY__ENV__DATABASE_NAME: wallabag | |
SYMFONY__ENV__DATABASE_USER: admin | |
SYMFONY__ENV__DATABASE_PASSWORD: ${HOMELAB_SECRET} | |
SYMFONY__ENV__MAILER_TRANSPORT: smtp | |
SYMFONY__ENV__MAILER_HOST: ${HOMELAB_SMTP_HOST} | |
SYMFONY__ENV__MAILER_PORT: ${HOMELAB_SMTP_PORT} | |
SYMFONY__ENV__MAILER_ENCRYPTION: ${HOMELAB_SMTP_SECURE} | |
SYMFONY__ENV__MAILER_AUTH_MODE: login | |
SYMFONY__ENV__MAILER_USER: ${HOMELAB_SMTP_NAME} | |
SYMFONY__ENV__MAILER_PASSWORD: ${HOMELAB_SMTP_PASSWORD} | |
SYMFONY__ENV__FROM_EMAIL: wallabag@${HOMELAB_DOMAIN} | |
SYMFONY__ENV__DOMAIN_NAME: https://wallabag.${HOMELAB_DOMAIN} | |
SYMFONY__ENV__SERVER_NAME: "wallabag" | |
SYMFONY__ENV__SECRET: ${HOMELAB_SECRET} | |
SYMFONY__ENV__FOSUSER_CONFIRMATION: "false" | |
SYMFONY__ENV__FOSUSER_REGISTRATION: "false" | |
ports: | |
- target: 80 | |
volumes: | |
- data:/var/www/wallabag/data | |
- images:/var/www/wallabag/web/assets/images | |
- /etc/localtime:/etc/localtime:ro | |
networks: | |
- wallabag | |
- traefik | |
# https://hub.docker.com/_/postgres | |
db: | |
image: "postgres:alpine" | |
command: "postgres -N 500" | |
deploy: | |
mode: replicated | |
replicas: 1 | |
environment: | |
POSTGRES_USER: admin | |
POSTGRES_PASSWORD: ${HOMELAB_SECRET} | |
POSTGRES_DB: wallabag | |
ports: | |
- target: 5432 | |
volumes: | |
- db:/var/lib/postgresql/data | |
- /etc/localtime:/etc/localtime:ro | |
networks: | |
- wallabag | |
# https://hub.docker.com/_/redis | |
redis: | |
image: "redis:alpine" | |
deploy: | |
mode: replicated | |
replicas: 1 | |
command: > | |
redis-server | |
--databases 1 | |
--maxmemory 50mb | |
--maxmemory-policy allkeys-lru | |
ports: | |
- target: 6379 | |
volumes: | |
- redis:/data | |
networks: | |
- wallabag | |
volumes: | |
data: | |
images: | |
db: | |
redis: | |
networks: | |
wallabag: | |
name: wallabag | |
driver: overlay | |
attachable: true | |
traefik: | |
name: traefik | |
driver: overlay | |
attachable: true | |
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker stack deploy -c stack-wallabag.yml wallabag | |
./wallabag init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install or update | |
# bin/wallabag init | |
# | |
# Run database commands | |
# bin/wallabag db | |
# | |
# Create new user: | |
# bin/wallabag fos:user:create | |
# | |
# Change user password: | |
# bin/wallabag fos:user:change-password | |
# | |
# All console commands | |
# https://doc.wallabag.org/en/admin/console_commands.html | |
# Run console commands on the wallabag_web container | |
console() { | |
local name="wallabag_web" | |
local id=$(docker ps -f name=$name --quiet | head -n1) # lookup container id | |
[ -z "$id" ] && echo "> $name not running" && exit 1 # exit if container missing | |
docker exec -it --user nobody $id /var/www/wallabag/bin/console --env=prod $@ | |
} | |
# Run database commands on the wallabag_db container | |
db() { | |
local name="wallabag_db" | |
local id=$(docker ps -f name=$name --quiet | head -n1) # lookup container id | |
[ -z "$id" ] && echo "> $name not running" && exit 1 # exit if container missing | |
local q=""; [ "$1" != "" ] && q="-c \"$@\"" # psql query | |
docker exec -it $id bash -c "PGPASSWORD=$HOMELAB_SECRET psql -h db -U admin wallabag $q" | |
} | |
# Pass "db" arg for psql command line | |
if [ "$1" = "db" ]; then | |
db | |
# Pass "init" arg if installing/updating | |
elif [ "$1" = "init" ]; then | |
# Detect installation status by listing all tables in the database | |
if [ -z "$(db '\dt' | grep wallabag_user)" ]; then | |
# If there is no wallabag_user table, run the install command | |
console --no-interaction wallabag:install | |
# Otherwise, assume it's installed and run the migrate command | |
else | |
console --no-interaction doctrine:migrations:migrate | |
fi | |
# Anything else gets run as commands for wallabag's console | |
else | |
console $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment