fix: parse env variables
This commit is contained in:
parent
31be2a7117
commit
81e8ecd289
5 changed files with 152 additions and 60 deletions
|
@ -1,8 +1,9 @@
|
|||
FROM wallabag/wallabag:2.6.9
|
||||
|
||||
# Copy custom entrypoint script
|
||||
COPY --chown=wallabag:wallabag --chmod=755 entrypoint-wrapper.sh /entrypoint-wrapper.sh
|
||||
COPY --chown=root:root --chmod=755 parse-database-url.sh /usr/local/bin/parse-database-url.sh
|
||||
COPY --chown=root:root --chmod=755 entrypoint-wrapper.sh /usr/local/bin/entrypoint-wrapper.sh
|
||||
|
||||
# Set the custom entrypoint
|
||||
ENTRYPOINT ["/entrypoint-wrapper.sh"]
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint-wrapper.sh"]
|
||||
CMD ["wallabag"]
|
||||
|
|
89
README.md
89
README.md
|
@ -1,26 +1,71 @@
|
|||
[](https://cicd.apps.glenux.net/glenux-opencontainers/service-wallabag)
|
||||
|
||||
# Wallabag
|
||||
|
||||
## Setup on Dokku
|
||||
|
||||
Create app
|
||||
|
||||
export APP=wallabag
|
||||
dokku apps:create $APP
|
||||
|
||||
Setup network and domains
|
||||
|
||||
Setup storage
|
||||
|
||||
mkdir -p /home/data/$APP.wallabag/images
|
||||
dokku storage:mount $APP /home/data/$APP.wallabag/images:/var/www/wallabag/web/assets/images
|
||||
|
||||
Setup database
|
||||
|
||||
dokku postgres:create $APP
|
||||
dokku postgres:link $APP $APP
|
||||
|
||||
Setup cache
|
||||
|
||||
dokku redis:create $APP
|
||||
dokku redis:link $APP $APP
|
||||
|
||||
Setup configuration
|
||||
|
||||
dokku config:set --no-restart $APP SYMFONY__ENV__DATABASE_DRIVER=pdo_pgsql
|
||||
dokku config:set --no-restart $APP DATABASE_URL=postgresql://wallabag:wallapass@db:5432/wallabag
|
||||
dokku config:set --no-restart $APP SYMFONY__ENV__DATABASE_TABLE_PREFIX="wallabag_"
|
||||
dokku config:set --no-restart $APP SYMFONY__ENV__MAILER_DSN=smtp://127.0.0.1
|
||||
dokku config:set --no-restart $APP SYMFONY__ENV__FROM_EMAIL=$APP@example.com
|
||||
dokku config:set --no-restart $APP SYMFONY__ENV__DOMAIN_NAME=https://your-$APP-instance.$APP.org
|
||||
dokku config:set --no-restart $APP SYMFONY__ENV__SERVER_NAME="Your $APP instance"
|
||||
|
||||
Setup letsencrypt
|
||||
|
||||
dokku letsencrypt:set $APP email $APP@example.com
|
||||
dokku letsencrypt:enable $APP
|
||||
|
||||
Deploy
|
||||
|
||||
git remote add dokku dokku@example.com:$APP
|
||||
git push
|
||||
|
||||
## Post-install
|
||||
|
||||
docker compose run $APP -- exec su -c "bin/console list --env=prod" -s /bin/sh nobody
|
||||
|
||||
docker compose exec $APP su -c "bin/console fos:user:create --super --env=prod" -s /bin/sh nobody
|
||||
docker compose exec $APP su -c "bin/console fos:user:promote --super --env=prod" -s /bin/sh nobody
|
||||
|
||||
## Setup on host
|
||||
|
||||
|
||||
dokku apps:create wallabag
|
||||
|
||||
Add cronjobs
|
||||
|
||||
FROM wallabag/wallabag
|
||||
|
||||
The end and, hopefully, success.
|
||||
|
||||
## Reference
|
||||
|
||||
* https://doc.wallabag.org/fr/developer/docker
|
||||
* https://hub.docker.com/r/wallabag/wallabag/
|
||||
|
||||
|
||||
dokku mariadb:create wallabag_db
|
||||
dokku mariadb:link wallabag_db wallabag
|
||||
dokku redis:create wallabag_redis
|
||||
dokku redis:link wallabag_redis wallabag
|
||||
dokku config:set wallabag MYSQL_ROOT_PASSWORD=wallaroot
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_DRIVER=pdo_mysql
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_HOST=$(dokku mariadb:info wallabag_db --dsn | grep '^Host=' | cut -d= -f2)
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_PORT=3306
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_NAME=wallabag
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_USER=wallabag
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_PASSWORD=wallapass
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_CHARSET=utf8mb4
|
||||
dokku config:set wallabag SYMFONY__ENV__DATABASE_TABLE_PREFIX="wallabag_"
|
||||
dokku config:set wallabag SYMFONY__ENV__MAILER_DSN=smtp://127.0.0.1
|
||||
dokku config:set wallabag SYMFONY__ENV__FROM_EMAIL=wallabag@example.com
|
||||
dokku config:set wallabag SYMFONY__ENV__DOMAIN_NAME=https://your-wallabag-instance.wallabag.org
|
||||
dokku config:set wallabag SYMFONY__ENV__SERVER_NAME="Your wallabag instance"
|
||||
mkdir -p /opt/wallabag/images
|
||||
dokku storage:mount wallabag /opt/wallabag/images:/var/www/wallabag/web/assets/images
|
||||
FROM wallabag/wallabag
|
||||
|
||||
|
|
|
@ -1,45 +1,55 @@
|
|||
---
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
wallabag:
|
||||
image: wallabag/wallabag
|
||||
build: .
|
||||
image: glenux/service-wallabag
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=wallaroot
|
||||
- SYMFONY__ENV__DATABASE_DRIVER=pdo_mysql
|
||||
- SYMFONY__ENV__DATABASE_HOST=db
|
||||
- SYMFONY__ENV__DATABASE_PORT=3306
|
||||
- SYMFONY__ENV__DATABASE_NAME=wallabag
|
||||
- SYMFONY__ENV__DATABASE_USER=wallabag
|
||||
- SYMFONY__ENV__DATABASE_PASSWORD=wallapass
|
||||
- SYMFONY__ENV__DATABASE_CHARSET=utf8mb4
|
||||
- SYMFONY__ENV__DATABASE_TABLE_PREFIX="wallabag_"
|
||||
- SYMFONY__ENV__MAILER_DSN=smtp://127.0.0.1
|
||||
- SYMFONY__ENV__FROM_EMAIL=wallabag@example.com
|
||||
- SYMFONY__ENV__DOMAIN_NAME=https://your-wallabag-instance.wallabag.org
|
||||
- SYMFONY__ENV__SERVER_NAME="Your wallabag instance"
|
||||
SYMFONY__ENV__DATABASE_DRIVER: pdo_pgsql
|
||||
DATABASE_URL: postgresql://wallabag:wallapass@db:5432/wallabag
|
||||
# SYMFONY__ENV__DATABASE_NAME: wallabag
|
||||
# SYMFONY__ENV__DATABASE_USER: wallabag
|
||||
# SYMFONY__ENV__DATABASE_PASSWORD: wallapass
|
||||
SYMFONY__ENV__DATABASE_TABLE_PREFIX: "wallabag_"
|
||||
SYMFONY__ENV__MAILER_DSN: smtp://127.0.0.1
|
||||
SYMFONY__ENV__FROM_EMAIL: wallabag@example.com
|
||||
SYMFONY__ENV__DOMAIN_NAME: http://localhost:8080
|
||||
SYMFONY__ENV__FOSUSER_REGISTRATION: true
|
||||
SYMFONY__ENV__FOSUSER_CONFIRMATION: false
|
||||
# your-wallabag-instance.wallabag.org
|
||||
SYMFONY__ENV__SERVER_NAME: "Your wallabag instance"
|
||||
ports:
|
||||
- "80"
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- /opt/wallabag/images:/var/www/wallabag/web/assets/images
|
||||
- images_data:/var/www/wallabag/web/assets/images
|
||||
healthcheck:
|
||||
test: ["CMD", "wget" ,"--no-verbose", "--tries=1", "--spider", "http://localhost"]
|
||||
interval: 1m
|
||||
timeout: 3s
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
|
||||
db:
|
||||
image: mariadb
|
||||
image: postgres:latest
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=wallaroot
|
||||
POSTGRES_PASSWORD: wallapass
|
||||
POSTGRES_USER: wallabag
|
||||
POSTGRES_DB: wallabag
|
||||
|
||||
volumes:
|
||||
- /opt/wallabag/data:/var/lib/mysql
|
||||
- db_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||
interval: 20s
|
||||
timeout: 3s
|
||||
|
||||
redis:
|
||||
image: redis:alpine
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 20s
|
||||
timeout: 3s
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
images_data:
|
||||
|
||||
|
|
25
entrypoint-wrapper.sh
Normal file → Executable file
25
entrypoint-wrapper.sh
Normal file → Executable file
|
@ -1,16 +1,17 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# vim: set ts=2 sw=2 et ft=bash:
|
||||
|
||||
# Parse DATABASE_URL
|
||||
if [ -n "$DATABASE_URL" ]; then
|
||||
export SYMFONY__ENV__DATABASE_DRIVER=$(echo $DATABASE_URL | sed -e 's,^\(.*\)://.*,\\1,g')
|
||||
export SYMFONY__ENV__DATABASE_USER=$(echo $DATABASE_URL | sed -e 's,.*://\([^:]*\):.*,\1,g')
|
||||
export SYMFONY__ENV__DATABASE_PASSWORD=$(echo $DATABASE_URL | sed -e 's,.*:.\([^@]*\)@.*,\\1,g')
|
||||
export SYMFONY__ENV__DATABASE_HOST=$(echo $DATABASE_URL | sed -e 's,.*@\([^:]*\):.*,\\1,g')
|
||||
export SYMFONY__ENV__DATABASE_PORT=$(echo $DATABASE_URL | sed -e 's,.*:\([^/]*\)/.*,\\1,g')
|
||||
export SYMFONY__ENV__DATABASE_NAME=$(echo $DATABASE_URL | sed -e 's,.*\/\([^?]*\).*,\\1,g')
|
||||
fi
|
||||
eval "$(/usr/local/bin/parse-database-url.sh "${DATABASE_URL:-}" SYMFONY__ENV__DATABASE |sed -e 's/^/export /')"
|
||||
|
||||
# Call the original entrypoint
|
||||
exec docker-php-entrypoint "$@"
|
||||
# Rename variables
|
||||
SYMFONY__ENV__DATABASE_PASSWORD="$SYMFONY__ENV__DATABASE_PASS"
|
||||
export SYMFONY__ENV__DATABASE_PASSWORD
|
||||
|
||||
env
|
||||
|
||||
echo "=== entrypoint"
|
||||
cat /entrypoint.sh
|
||||
|
||||
echo "changing entrypoint..."
|
||||
echo /entrypoint.sh # "$@"
|
||||
exec /entrypoint.sh "$@"
|
||||
|
|
35
parse-database-url.sh
Executable file
35
parse-database-url.sh
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
# Referenced and tweaked from http://stackoverflow.com/questions/6174220/parse-url-in-shell-script#6174447
|
||||
|
||||
url="$1"
|
||||
prefix="$2"
|
||||
proto="$(echo "$url" | grep :// | sed -e 's,^\(.*\)://.*,\1,g')"
|
||||
# remove the protocol
|
||||
workurl="$(echo "$url" |sed -e "s,^$proto://,,")"
|
||||
# extract the user (if any)
|
||||
userpass="$(echo "$workurl" | grep @ | cut -d@ -f1)"
|
||||
pass="$(echo "$userpass"| grep : | cut -d: -f2)"
|
||||
if [ -n "$pass" ]; then
|
||||
user="$(echo "$userpass" | grep : | cut -d: -f1)"
|
||||
else
|
||||
user="$userpass"
|
||||
fi
|
||||
|
||||
# extract the host
|
||||
hostport="$(echo "$workurl" |sed -e "s,$userpass@,," | cut -d/ -f1)"
|
||||
# by request - try to extract the port
|
||||
port="$(echo "$hostport" | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
|
||||
host="$(echo "$hostport" | cut -d: -f1)"
|
||||
# extract the path (if any)
|
||||
path="/$(echo "$workurl" | grep / | cut -d/ -f2-)"
|
||||
name="$(echo "$workurl" | grep / | cut -d/ -f2-)"
|
||||
|
||||
echo "${prefix}_URL=\"$url\""
|
||||
echo "${prefix}_PROTO=\"$proto\""
|
||||
echo "${prefix}_USER=\"$user\""
|
||||
echo "${prefix}_PASS=\"$pass\""
|
||||
echo "${prefix}_HOST=\"$host\""
|
||||
echo "${prefix}_PORT=\"$port\""
|
||||
echo "${prefix}_PATH=\"$path\""
|
||||
echo "${prefix}_NAME=\"$name\""
|
||||
|
Loading…
Add table
Reference in a new issue