Skip to content

Commit d17b1dd

Browse files
committed
Initial commit
1 parent cdc832d commit d17b1dd

File tree

7 files changed

+340
-0
lines changed

7 files changed

+340
-0
lines changed

.env.docker.example

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
COMPOSE_SERVER_DOMAIN=demo.os2display.dk
2+
3+
# Version of itkdev/os2display-api-service
4+
# Find the latest version here: https://hub.docker.com/r/itkdev/os2display-api-service/tags
5+
# Put COMPOSE_VERSION_API=develop if you want to install the dev-branch.
6+
COMPOSE_VERSION_API=2.2.0
7+
8+
# Version of itkdev/os2display-admin-client
9+
# Find the latest version here: https://hub.docker.com/r/itkdev/os2display-admin-client/tags
10+
COMPOSE_VERSION_ADMIN=2.2.0
11+
12+
# Version of itkdev/os2display-client
13+
# Find the latest version here: https://hub.docker.com/r/itkdev/os2display-client/tags
14+
COMPOSE_VERSION_CLIENT=2.1.2
15+
16+
# Version of github.com/os2display/display-templates
17+
# Find the latest version here: https://github.com/os2display/display-templates/releases
18+
TASK_VERSION_TEMPLATES=2.2.0
19+
20+
# List the templates you want to load.
21+
# Find all available templates here: https://github.com/os2display/display-templates/tree/develop/src
22+
TASK_TEMPLATES="book-review,calendar,contacts,iframe,image-text,instagram-feed,news-feed,poster,rss,slideshow,table,travel,video"
23+
24+
# List the screen layouts you want to load.
25+
# Find all available templates here: https://github.com/os2display/display-templates/tree/develop/src/screen-layouts
26+
TASK_SCREEN_LAYOUTS="full-screen,three-boxes-horizontal,three-boxes,touch-template,two-boxes,two-boxes-vertical,six-areas,four-areas"
27+
28+
# Have docker compose include a MariaDB database or configure an external one?
29+
# Set to 'true' to use the built-in MariaDB database provided by the Docker Compose setup.
30+
# Set to 'false' to configure and use an external MariaDB database.
31+
INTERNAL_DATABASE=true
32+
33+
# Have docker compose include a Traefik proxy or configure an external one?
34+
# Set to 'true' to use the built-in Traefik proxy provided by the Docker Compose setup.
35+
# Set to 'false' to configure and use an external Traefik proxy.
36+
INTERNAL_PROXY=true
37+
38+
# mysql://<username>:<password>@<host>:<port>/<database>?serverVersion=<server_version>
39+
# APP_DATABASE_URL syntax:
40+
# - <username>: The username for the database connection
41+
# - <password>: The password for the database connection
42+
# - <host>: The hostname or IP address of the database server
43+
# - <port>: The port number on which the database server is listening (default for MySQL is 3306)
44+
# - <database>: The name of the database to connect to
45+
# - <server_version>: The version of the database server (used by Doctrine to generate compatible SQL queries)
46+
APP_DATABASE_URL="mysql://db:db@mariadb:3306/db?serverVersion=mariadb-10.11.11"
47+
48+
# Note: When updating the database connection details, ensure that the following MariaDB variables
49+
# are also updated to match the connection string above. These variables are used by the Docker
50+
# Compose setup to configure the built-in MariaDB service. These variables are only necessary if
51+
# the local MariaDB service is used (COMPOSE_INTERNAL_DATABASE=true).
52+
MARIADB_USER=db
53+
MARIADB_PASSWORD=db
54+
MARIADB_ROOT_PASSWORD=dbrootpassword
55+
MARIADB_DATABASE=db
56+
DB_HOST=mariadb
57+
58+
# Use a built-in Traefik proxy or configure one externally?
59+
# Set to 'true' to use the built-in Traefik proxy provided by the Docker Compose setup.
60+
# Set to 'false' to configure and use an external proxy.
61+
COMPOSE_INTERNAL_PROXY=true
62+
63+
APP_SECRET=
64+
APP_JWT_PASSPHRASE=
65+
66+
##### client [itkdev/os2display-client] #####
67+
APP_API_ENDPOINT="https://demo.os2display.dk"
68+
APP_API_PATH="https://demo.os2display.dk"
69+
APP_API_AUTHENTICATION_ENDPOINT="https://demo.os2display.dk/v1/authentication/screen"
70+
APP_API_AUTHENTICATION_REFRESH_ENDPOINT="https://demo.os2display.dk/v1/authentication/token/refresh"

Taskfile.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
version: '3'
2+
silent: true
3+
4+
tasks:
5+
default:
6+
desc: The default task that shows help
7+
cmds:
8+
- task --list
9+
10+
install:
11+
desc: Install the project
12+
deps:
13+
- _dc_compile
14+
cmds:
15+
- task _show_preinstall_notes
16+
- echo "Installing"
17+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml pull
18+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml up --force-recreate --detach --remove-orphans
19+
- echo "Waiting for database to be ready"
20+
- sleep 10
21+
- echo "Initialize the database"
22+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml exec api bin/console doctrine:schema:create
23+
- echo "Clearing the cache"
24+
- task cc
25+
- echo "Create jwt key pair"
26+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml exec --user 1000:1000 api bin/console lexik:jwt:generate-keypair --skip-if-exists
27+
- task tenant_add
28+
- echo "CREATE AN ADMIN USER. CHOOSE THE TENANT YOU JUST CREATED."
29+
- task user_add
30+
- task load_templates
31+
- task _show_notes
32+
33+
reinstall:
34+
desc: Reinstall from scratch. Removes the database, all containers, and volumes.
35+
deps:
36+
- down
37+
cmds:
38+
- task install
39+
40+
down:
41+
desc: Remove all containers and volumes
42+
deps:
43+
- stop
44+
cmds:
45+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml down -v
46+
47+
up:
48+
desc: Take the environment up without altering the existing state of the containers
49+
cmds:
50+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml up -d
51+
52+
stop:
53+
desc: Stop all containers without altering anything else
54+
cmds:
55+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml stop
56+
57+
tenant_add:
58+
desc: Add a new tenant group
59+
cmds:
60+
- echo ""
61+
- echo "Add a tenant"
62+
- echo "===================================================="
63+
- echo "A tenant is a group of users that share the same configuration. F. ex. IT, Library, Schools etc."
64+
- echo "You have to provide tenant id, tenant title and optionally a description."
65+
- echo "===================================================="
66+
- echo ""
67+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml exec -T api bin/console app:tenant:add
68+
69+
user_add:
70+
desc: Add a new user (editor or admin)
71+
cmds:
72+
- echo ""
73+
- echo "Add a user"
74+
- echo "===================================================="
75+
- echo "You have to provide email, password, full name, role (editor or admin) and the tenant id."
76+
- echo "===================================================="
77+
- echo ""
78+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml exec -T api bin/console app:user:add
79+
80+
load_templates:
81+
desc: Load templates and screen layouts
82+
cmds:
83+
- |
84+
TEMPLATES_RELEASE=$(grep ^TASK_VERSION_TEMPLATES= .env.docker.local | cut -d '=' -f 2)
85+
TEMPLATES=$(grep ^TASK_TEMPLATES= .env.docker.local | cut -d '=' -f 2 | tr -d ' "' | tr ',' ' ')
86+
if [ -z "$TEMPLATES_RELEASE" ]; then
87+
echo "Error: TASK_VERSION_TEMPLATES is not set in .env.docker.local"
88+
exit 1
89+
fi
90+
if [ -z "$TEMPLATES" ]; then
91+
echo "Error: TASK_TEMPLATES is not set or empty in .env.docker.local"
92+
exit 1
93+
fi
94+
echo "Using TEMPLATES_RELEASE=$TEMPLATES_RELEASE"
95+
echo "Using TEMPLATES=$TEMPLATES"
96+
for TEMPLATE in $TEMPLATES; do
97+
CONFIG_URL="https://raw.githubusercontent.com/os2display/display-templates/refs/tags/$TEMPLATES_RELEASE/build/$TEMPLATE-config-main.json"
98+
echo "Loading template: $TEMPLATE"
99+
docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml exec --user deploy api bin/console app:template:load -p $CONFIG_URL
100+
done
101+
102+
SCREEN_LAYOUTS=$(grep ^TASK_SCREEN_LAYOUTS= .env.docker.local | cut -d '=' -f 2 | tr -d ' "' | tr ',' ' ')
103+
if [ -z "$SCREEN_LAYOUTS" ]; then
104+
echo "Error: TASK_SCREEN_LAYOUTS is not set or empty in .env.docker.local"
105+
exit 1
106+
fi
107+
echo "Using SCREEN_LAYOUTS=$SCREEN_LAYOUTS"
108+
for SCREEN_LAYOUT in $SCREEN_LAYOUTS; do
109+
CONFIG_URL="https://raw.githubusercontent.com/os2display/display-templates/refs/tags/$TEMPLATES_RELEASE/src/screen-layouts/$SCREEN_LAYOUT.json"
110+
echo "Loading screen layout: $SCREEN_LAYOUT"
111+
docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml exec --user deploy api bin/console app:screen-layouts:load --update --cleanup-regions $CONFIG_URL
112+
done
113+
114+
logs:
115+
desc: Follow docker logs from the containers
116+
cmds:
117+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml logs -f --tail=50
118+
119+
cc:
120+
desc: Clear the cache
121+
cmds:
122+
- docker compose --env-file .env.local --env-file .env.docker.local -f docker-compose.yml exec api bin/console cache:clear
123+
124+
_show_preinstall_notes:
125+
cmds:
126+
- echo ""
127+
- echo "===================================================="
128+
- echo "Pre-installation Requirements"
129+
- echo "===================================================="
130+
- echo ""
131+
- echo "- Edit .env.docker.local and provide your own configuration settings."
132+
- echo "- Copy your SSL certificate files (docker.crt and docker.key) to the ssl-folder"
133+
- echo ""
134+
- echo "Have you completed the above pre-install requirements? (yes/no)"
135+
- |
136+
read answer && case $answer in
137+
[Yy][Ee][Ss]) ;;
138+
*) echo "Please complete the pre-install tasks before continuing."; exit 1;;
139+
esac
140+
141+
_show_notes:
142+
cmds:
143+
- |
144+
DOMAIN=$(grep ^COMPOSE_SERVER_DOMAIN= .env.docker.local | cut -d '=' -f 2)
145+
echo ""
146+
echo "===================================================="
147+
echo "OS2display now is available via the URLs below"
148+
echo "===================================================="
149+
echo "Admin: https://$DOMAIN/admin"
150+
echo "Screen: https://$DOMAIN/screen"
151+
echo "===================================================="
152+
153+
_env_files:
154+
cmds:
155+
- |
156+
if [ ! -f .env.local ]; then
157+
echo ".env.local does not exist. Copying .env.example to .env.local..."
158+
cp .env.example .env.local
159+
fi
160+
- |
161+
if [ ! -f .env.docker.local ]; then
162+
echo ".env.docker.local does not exist. Copying .env.docker.example to .env.docker.local..."
163+
cp .env.docker.example .env.docker.local
164+
fi
165+
166+
_dc_compile:
167+
deps:
168+
- _env_files
169+
cmds:
170+
- |
171+
COMPOSE_FILES="-f docker-compose.server.yml"
172+
if grep -q '^INTERNAL_DATABASE=true' .env.docker.local; then
173+
COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.mariadb.yml"
174+
fi
175+
if grep -q '^INTERNAL_PROXY=true' .env.docker.local; then
176+
COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.traefik.yml"
177+
fi
178+
docker compose --env-file .env.local --env-file .env.docker.local $COMPOSE_FILES config > docker-compose.yml

docker-compose.mariadb.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
networks:
2+
app:
3+
driver: bridge
4+
internal: false
5+
6+
services:
7+
mariadb:
8+
image: mariadb:10.11.11
9+
restart: unless-stopped
10+
networks:
11+
- app
12+
environment:
13+
- MARIADB_DATABASE=${MARIADB_DATABASE}
14+
- MARIADB_USER=${MARIADB_USER}
15+
- MARIADB_PASSWORD=${MARIADB_PASSWORD}
16+
- MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
17+
volumes:
18+
- mariadb:/var/lib/mysql:rw
19+
20+
volumes:
21+
mariadb:

docker-compose.traefik.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
networks:
2+
proxy:
3+
driver: bridge
4+
internal: true
5+
6+
services:
7+
traefik:
8+
image: traefik:v3.2
9+
container_name: traefik
10+
restart: unless-stopped
11+
security_opt:
12+
- no-new-privileges:true
13+
ports:
14+
- "80:80"
15+
- "443:443"
16+
- "8080:8080" # Dashboard
17+
volumes:
18+
- $PWD/traefik/ssl:/certs:ro
19+
- $PWD/traefik/traefik.yml:/traefik.yml:ro
20+
- $PWD/traefik/dynamic-conf.yaml:/config/dynamic-conf.yaml:ro
21+
networks:
22+
- frontend
23+
- proxy
24+
25+
socket-proxy:
26+
image: itkdev/docker-socket-proxy
27+
user: root
28+
container_name: socket-proxy
29+
restart: unless-stopped
30+
volumes:
31+
- /var/run/docker.sock:/var/run/docker.sock:ro
32+
environment:
33+
CONTAINERS: 1
34+
networks:
35+
- proxy

traefik/dynamic-conf.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tls:
2+
certificates:
3+
- certFile: /certs/docker.crt
4+
keyFile: /certs/docker.key
5+

traefik/ssl/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

traefik/traefik.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
api:
3+
dashboard: true
4+
insecure: true
5+
debug: true
6+
7+
entryPoints:
8+
web:
9+
address: ":80"
10+
websecure:
11+
address: ":443"
12+
http:
13+
tls:
14+
{}
15+
16+
providers:
17+
file:
18+
directory: /config
19+
docker:
20+
endpoint: "tcp://socket-proxy:2375"
21+
exposedByDefault: false
22+
23+
# https://doc.traefik.io/traefik/routing/services/#insecureskipverify
24+
serversTransport:
25+
insecureSkipVerify: true
26+
27+

0 commit comments

Comments
 (0)