Skip to content

Commit

Permalink
Add ability to run datalens with docker volumes (#214)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Actions <[email protected]>
Co-authored-by: GitHub Action <>
  • Loading branch information
goshander and web-flow authored Nov 27, 2024
1 parent 0393de8 commit 27605f9
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 25 deletions.
6 changes: 3 additions & 3 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
pg-compeng:
container_name: datalens-pg-compeng
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: postgres
Expand Down Expand Up @@ -47,7 +47,7 @@ services:

pg-demo-connection:
container_name: datalens-pg-demo-connection
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: demo
POSTGRES_USER: demo
Expand All @@ -58,7 +58,7 @@ services:

pg-us:
container_name: datalens-pg-us
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: us-db-ci_purgeable
POSTGRES_USER: us
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
pg-compeng:
container_name: datalens-pg-compeng
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: postgres
Expand Down Expand Up @@ -43,24 +43,24 @@ services:

pg-demo-connection:
container_name: datalens-pg-demo-connection
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: demo
POSTGRES_USER: demo
POSTGRES_PASSWORD: demo
volumes:
- ./pg-demo-connection/data:/var/lib/postgresql/data
- ${VOLUME_DEMO:-./pg-demo-connection/data}:/var/lib/postgresql/data
- ./pg-demo-connection/init:/docker-entrypoint-initdb.d

pg-us:
container_name: datalens-pg-us
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: us-db-ci_purgeable
POSTGRES_USER: us
POSTGRES_PASSWORD: us
volumes:
- ./metadata:/var/lib/postgresql/data
- ${VOLUME_US:-./metadata}:/var/lib/postgresql/data

us:
container_name: datalens-us
Expand Down
17 changes: 11 additions & 6 deletions docker-compose.zitadel.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
pg-compeng:
container_name: datalens-pg-compeng
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: postgres
Expand Down Expand Up @@ -59,24 +59,24 @@ services:

pg-demo-connection:
container_name: datalens-pg-demo-connection
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: demo
POSTGRES_USER: demo
POSTGRES_PASSWORD: demo
volumes:
- ./pg-demo-connection/init:/docker-entrypoint-initdb.d
- ./pg-demo-connection/data:/var/lib/postgresql/data
- ${VOLUME_DEMO:-./pg-demo-connection/data}:/var/lib/postgresql/data

pg-us:
container_name: datalens-pg-us
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: us-db-ci_purgeable
POSTGRES_USER: us
POSTGRES_PASSWORD: us
volumes:
- ./metadata:/var/lib/postgresql/data
- ${VOLUME_US:-./metadata}:/var/lib/postgresql/data

us:
container_name: datalens-us
Expand Down Expand Up @@ -120,7 +120,7 @@ services:
ports:
- "8087:5432"
volumes:
- ./zitadel-db:/var/lib/postgresql/data
- ${VOLUME_ZITADEL:-./zitadel-db}:/var/lib/postgresql/data

zitadel:
restart: 'always'
Expand Down Expand Up @@ -194,3 +194,8 @@ services:
ZITADEL_COOKIE_SECRET: ${ZITADEL_COOKIE_SECRET:?missed ZITADEL_COOKIE_SECRET env}"
SERVICE_CLIENT_ID: "charts"
SERVICE_CLIENT_SECRET: "${CHARTS_SERVICE_CLIENT_SECRET}"

volumes:
db-us:
db-zitadel:
db-demo:
13 changes: 13 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ delete_admin_service_user() {
start_compose() {
DOCKER_COMPOSE_CONFIG=docker-compose.zitadel.yml

if [ "${USE_DOCKER_VOLUMES}" == "true" ]; then
export VOLUME_ZITADEL="db-zitadel"
export VOLUME_US="db-us"
export VOLUME_DEMO="db-demo"
fi

$(get_docker_compose_command) -f ${DOCKER_COMPOSE_CONFIG} up -d
}

Expand Down Expand Up @@ -473,6 +479,13 @@ install_zitadel() {
generate_secret ZITADEL_COOKIE_SECRET 32
generate_secret US_MASTER_TOKEN 32

if [ "${USE_DOCKER_VOLUMES}" == "true" ]; then
write_env USE_DOCKER_VOLUMES "${USE_DOCKER_VOLUMES}"
export VOLUME_ZITADEL="db-zitadel"
export VOLUME_US="db-us"
export VOLUME_DEMO="db-demo"
fi

start_zitadel

if [ ! -z "${ZITADEL_ADMIN_ACCESS_TOKEN}" ]; then
Expand Down
10 changes: 5 additions & 5 deletions templates/docker-compose.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
pg-compeng:
container_name: datalens-pg-compeng
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: postgres
Expand Down Expand Up @@ -51,7 +51,7 @@ services:

pg-demo-connection:
container_name: datalens-pg-demo-connection
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: demo
POSTGRES_USER: demo
Expand All @@ -61,13 +61,13 @@ services:
- db-demo:/var/lib/postgresql/data
- ./pg-demo-connection/init:/docker-entrypoint-initdb.d
{%- else %}
- ./pg-demo-connection/data:/var/lib/postgresql/data
- ${VOLUME_DEMO:-./pg-demo-connection/data}:/var/lib/postgresql/data
- ./pg-demo-connection/init:/docker-entrypoint-initdb.d
{%- endif %}

pg-us:
container_name: datalens-pg-us
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: us-db-ci_purgeable
POSTGRES_USER: us
Expand All @@ -76,7 +76,7 @@ services:
{%- if env.get('DEV_MODE') %}
- db-us:/var/lib/postgresql/data
{%- else %}
- ./metadata:/var/lib/postgresql/data
- ${VOLUME_US:-./metadata}:/var/lib/postgresql/data
{%- endif %}
{%- if env.get('DEV_MODE') %}
ports:
Expand Down
17 changes: 11 additions & 6 deletions templates/docker-compose.zitadel.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
pg-compeng:
container_name: datalens-pg-compeng
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: postgres
Expand Down Expand Up @@ -70,24 +70,24 @@ services:

pg-demo-connection:
container_name: datalens-pg-demo-connection
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: demo
POSTGRES_USER: demo
POSTGRES_PASSWORD: demo
volumes:
- ./pg-demo-connection/init:/docker-entrypoint-initdb.d
- ./pg-demo-connection/data:/var/lib/postgresql/data
- ${VOLUME_DEMO:-./pg-demo-connection/data}:/var/lib/postgresql/data

pg-us:
container_name: datalens-pg-us
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_DB: us-db-ci_purgeable
POSTGRES_USER: us
POSTGRES_PASSWORD: us
volumes:
- ./metadata:/var/lib/postgresql/data
- ${VOLUME_US:-./metadata}:/var/lib/postgresql/data
{%- if env.get('DEV_MODE') %}
ports:
- "8086:5432"
Expand Down Expand Up @@ -140,7 +140,7 @@ services:
ports:
- "8087:5432"
volumes:
- ./zitadel-db:/var/lib/postgresql/data
- ${VOLUME_ZITADEL:-./zitadel-db}:/var/lib/postgresql/data

zitadel:
restart: 'always'
Expand Down Expand Up @@ -214,3 +214,8 @@ services:
ZITADEL_COOKIE_SECRET: ${ZITADEL_COOKIE_SECRET:?missed ZITADEL_COOKIE_SECRET env}"
SERVICE_CLIENT_ID: "charts"
SERVICE_CLIENT_SECRET: "${CHARTS_SERVICE_CLIENT_SECRET}"

volumes:
db-us:
db-zitadel:
db-demo:

0 comments on commit 27605f9

Please sign in to comment.