fix: running tenants migration on docker migration container

This commit is contained in:
Ahmed Bouhuolia
2023-09-25 15:31:09 +02:00
parent 597973d5d1
commit efebf424d1
3 changed files with 16 additions and 6 deletions

View File

@@ -15,8 +15,8 @@ services:
- ./data/logs/nginx/:/var/log/nginx - ./data/logs/nginx/:/var/log/nginx
- ./docker/certbot/certs/:/var/certs - ./docker/certbot/certs/:/var/certs
ports: ports:
- "${PUBLIC_PROXY_PORT:-80}:80" - '${PUBLIC_PROXY_PORT:-80}:80'
- "${PUBLIC_PROXY_SSL_PORT:-443}:443" - '${PUBLIC_PROXY_SSL_PORT:-443}:443'
tty: true tty: true
depends_on: depends_on:
- server - server
@@ -92,11 +92,14 @@ services:
context: ./ context: ./
dockerfile: docker/migration/Dockerfile dockerfile: docker/migration/Dockerfile
environment: environment:
# Database
- DB_HOST=mysql - DB_HOST=mysql
- DB_USER=${DB_USER} - DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD} - DB_PASSWORD=${DB_PASSWORD}
- DB_CHARSET=${DB_CHARSET} - DB_CHARSET=${DB_CHARSET}
- SYSTEM_DB_NAME=${SYSTEM_DB_NAME} - SYSTEM_DB_NAME=${SYSTEM_DB_NAME}
# Tenants databases
- TENANT_DB_NAME_PERFIX=${TENANT_DB_NAME_PERFIX}
depends_on: depends_on:
- mysql - mysql
@@ -136,7 +139,7 @@ services:
build: build:
context: ./docker/redis context: ./docker/redis
expose: expose:
- "6379" - '6379'
volumes: volumes:
- redis:/data - redis:/data

View File

@@ -34,5 +34,7 @@ WORKDIR /app/packages/server
RUN git clone https://github.com/vishnubob/wait-for-it.git RUN git clone https://github.com/vishnubob/wait-for-it.git
# Once we listen the mysql port run the migration task. ADD docker/migration/start.sh /
CMD ["./wait-for-it/wait-for-it.sh", "mysql:3306", "--", "node", "./build/commands.js", "system:migrate:latest"] RUN chmod +x /start.sh
CMD ["/start.sh"]

View File

@@ -0,0 +1,5 @@
# Migrate the master system database.
./wait-for-it/wait-for-it.sh mysql:3306 -- node ./build/commands.js system:migrate:latest
# Migrate all tenants.
./wait-for-it/wait-for-it.sh mysql:3306 -- node ./build/commands.js tenants:migrate:latest