Skip to content

Commit 710d3e5

Browse files
committed
Add Docker Secret support
1 parent 480d383 commit 710d3e5

7 files changed

Lines changed: 47 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- "sqlite"
2222
- "mariadb"
2323
- "postgresql"
24+
- "postgresql-secret"
2425

2526
steps:
2627
- name: "Checkout"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Default login is `wallabag:wallabag`.
4343
- `-e SYMFONY__ENV__SERVER_NAME=...` (defaults to "Your wallabag instance". Specifies a user-friendly name for the 2FA issuer)
4444
- `-e PHP_MEMORY_LIMIT=...` (allows you to change the PHP `memory_limit` value. defaults to 128M, and should be a number and unit, eg. 512K, 128M, 2G, or a number of bytes)
4545

46+
To set any of these environment variables from a file (for instance a Docker Secret), append `__FILE` to the name of the environment variable.
47+
4648
## SQLite
4749

4850
The easiest way to start wallabag is to use the SQLite backend. You can spin that up with

root/entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
# Exit when any command fails
33
set -e
44

5+
FILE_ENV_VARS="$(env | grep '__FILE=')"
6+
for env_var in $FILE_ENV_VARS; do
7+
var_name="$(echo "$env_var" | grep -o '.*__FILE=' | sed 's/__FILE=//g')"
8+
file_path="$(echo "$env_var" | grep -o '__FILE=.*' | sed 's/__FILE=//g')"
9+
file_content="$(cat "$file_path")"
10+
[ ! $? -eq 0 ] && exit 1 # Exit if last command failed
11+
new_var="$(echo "$var_name=$file_content")"
12+
export $(echo "$new_var" | xargs)
13+
done
14+
515
COMMAND_ARG1="$1"
616
COMMAND_ARG2="$2"
717

tests/credentials/db_password

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wallapass

tests/credentials/env_secret

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
F00B4R
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
my-secret-pw
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: '2'
2+
services:
3+
wallabag:
4+
build:
5+
context: ../
6+
image: wallabag:postgresql
7+
container_name: wallabag
8+
environment:
9+
- POSTGRES_PASSWORD__FILE=/run/secrets/postgres_password
10+
- POSTGRES_USER=my-super-user
11+
- SYMFONY__ENV__SECRET__FILE=/run/secrets/env_secret
12+
- SYMFONY__ENV__DATABASE_DRIVER=pdo_pgsql
13+
- SYMFONY__ENV__DATABASE_HOST=db
14+
- SYMFONY__ENV__DATABASE_PORT=5432
15+
- SYMFONY__ENV__DATABASE_NAME=wallabag
16+
- SYMFONY__ENV__DATABASE_USER=wallabag
17+
- SYMFONY__ENV__DATABASE_PASSWORD__FILE=/run/secrets/db_password
18+
ports:
19+
- "127.0.0.1:80:80"
20+
# Docker Secrets require Swarm Mode, so we use volumes instead to spoof the behaviour
21+
volumes:
22+
- ./credentials/db_password:/run/secrets/db_password
23+
- ./credentials/postgres_password:/run/secrets/postgres_password
24+
- ./credentials/env_secret:/run/secrets/env_secret
25+
db:
26+
image: postgres:18
27+
environment:
28+
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
29+
- POSTGRES_USER=my-super-user
30+
volumes:
31+
- ./credentials/postgres_password:/run/secrets/postgres_password

0 commit comments

Comments
 (0)