Skip to content

Commit 0627b54

Browse files
authored
run migrations in entrypoint (#697)
1 parent b06383f commit 0627b54

File tree

6 files changed

+14365
-433
lines changed

6 files changed

+14365
-433
lines changed

Dockerfile

+9-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ WORKDIR /usr/src/app
4848
# copy from build image
4949
COPY --from=development /usr/src/app/dist ./dist
5050
COPY --from=development /usr/src/app/node_modules ./node_modules
51-
COPY --from=development /usr/src/app/entrypoints ./
51+
52+
# required for migrations
53+
COPY libs/orm-migrations/ libs/orm-migrations/
54+
COPY ormconfig.js ./
55+
56+
# required for run
57+
COPY entrypoints/ ./
58+
COPY package.json ./
59+
COPY tsconfig.json ./
5260

5361
EXPOSE 3000
5462

docker-compose-dev.yml

+19
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,25 @@ services:
6969
- 8000:8000
7070
command: "-jar DynamoDBLocal.jar -sharedDb -dbPath /home/dynamodblocal/data/"
7171

72+
# api:
73+
# networks:
74+
# - postgres
75+
# - redis
76+
# env_file:
77+
# - .env.local
78+
# environment:
79+
# - NEST_APP_TYPE=api
80+
# - DATABASE_HOST=postgres
81+
# - DATABASE_PORT=5432
82+
# - REDIS_CACHE_URL=redis://@redis:6379/0
83+
# - REDIS_SOCKET_URL=redis://@redis:6379/1
84+
# - REDIS_EVENT_URL=redis://@redis:6379/2
85+
# - REDIS_CONNECTION_STRING=redis://@redis:6379/4
86+
# build:
87+
# context: .
88+
# args:
89+
# - APP_NAME=api
90+
7291
# TODO: Add opensearch docker containers (current containers are not working)
7392
# opensearch-node1:
7493
# image: opensearchproject/opensearch:latest

entrypoints/run.sh

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
#!/bin/sh
22

3-
if [ "$NEST_APP_TYPE" == "aggregator-dao" ]
4-
then
5-
node dist/apps/aggregator-dao/main.js
6-
elif [ "$NEST_APP_TYPE" == "aggregator" ]
7-
then
8-
node dist/apps/aggregator/main.js
9-
elif [ $NEST_APP_TYPE == "notifier" ]
10-
then
11-
node dist/apps/notifier/main.js
12-
elif [ $NEST_APP_TYPE == "draft" ]
13-
then
14-
node dist/apps/draft/main.js
15-
elif [ $NEST_APP_TYPE == "indexer-processor" ]
16-
then
17-
node dist/apps/indexer-processor/main.js
18-
else
19-
node dist/apps/api/main.js
20-
fi
3+
# exit when any command fails
4+
set -e
5+
6+
# run migrations
7+
npm run migration:run
8+
9+
# run app
10+
node dist/apps/$NEST_APP_TYPE/main.js

0 commit comments

Comments
 (0)