File tree 4 files changed +52
-6
lines changed
4 files changed +52
-6
lines changed Original file line number Diff line number Diff line change 1
- ARG BASE_IMAGE=node:12.18.2-alpine3.11
1
+ ARG BASE_IMAGE
2
2
3
3
FROM $BASE_IMAGE as base
4
4
5
- WORKDIR /app
5
+ WORKDIR /apps/database
6
6
7
- CMD yarn start
7
+ FROM base as dev
8
+
9
+ CMD yarn dev
10
+
11
+ FROM base as production_build
12
+
13
+ CMD yarn migrate
14
+
15
+ COPY apps/database/package.json apps/database/yarn.lock /apps/database/
16
+
17
+ RUN yarn --frozen-lockfile
18
+
19
+ COPY apps/database/ /apps/database/
Original file line number Diff line number Diff line change 1
1
{
2
2
"private" : true ,
3
+ "engines" : {
4
+ "node" : " >=15.8.0"
5
+ },
3
6
"scripts" : {
4
- "start " : " graphile-migrate watch" ,
7
+ "dev " : " graphile-migrate watch" ,
5
8
"commit" : " graphile-migrate commit" ,
6
- "mig-init" : " graphile-migrate init"
9
+ "mig-init" : " graphile-migrate init" ,
10
+ "migrate" : " graphile-migrate migrate" ,
11
+ "load" : " sh ./mig_data.sh" ,
12
+ "reset" : " graphile-migrate reset"
7
13
},
8
14
"dependencies" : {
9
15
"graphile-migrate" : " ^1.0.2"
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ version: "3.7"
3
3
services :
4
4
db :
5
5
image : postgres:13.1-alpine
6
+ environment :
7
+ POSTGRES_USER : $DATABASE_OWNER
8
+ POSTGRES_PASSWORD : $DATABASE_OWNER_PASSWORD
9
+ POSTGRES_DB : $DATABASE_NAME
6
10
env_file :
7
11
- .env
8
12
volumes :
@@ -11,17 +15,26 @@ services:
11
15
- 5432:5432
12
16
13
17
migrations :
18
+ environment :
19
+ ROOT_DATABASE_URL : postgres://$DATABASE_OWNER:$DATABASE_OWNER_PASSWORD@$DATABASE_HOST/template1
20
+ DATABASE_URL : postgres://$DATABASE_OWNER:$DATABASE_OWNER_PASSWORD@$DATABASE_HOST/$DATABASE_NAME
21
+ SHADOW_DATABASE_URL : postgres://$DATABASE_OWNER:$DATABASE_OWNER_PASSWORD@$DATABASE_HOST/${DATABASE_NAME}_shadow
14
22
build :
15
23
context : .
16
24
dockerfile : apps/database/Dockerfile
25
+ target : dev
26
+ args :
27
+ BASE_IMAGE : ${BASE_IMAGE_NODE_ALPINE}
17
28
volumes :
18
- - ./apps/database:/app
29
+ - ./apps/database:/apps/database
19
30
env_file :
20
31
- .env
21
32
depends_on :
22
33
- db
23
34
24
35
gql :
36
+ environment :
37
+ DATABASE_AUTHENTICATOR_URL : postgres://$DATABASE_AUTHENTICATOR:$DATABASE_AUTHENTICATOR_PASSWORD@$$DATABASE_HOST/$DATABASE_NAME
25
38
build :
26
39
context : .
27
40
target : dev
Original file line number Diff line number Diff line change
1
+ # exit when any command fails
2
+ set -e
3
+
4
+ echo " Bringing down all containers"
5
+ docker-compose down --volumes
6
+
7
+ echo " Building graphql and web containers"
8
+ docker-compose build --parallel migrations # gql
9
+
10
+ echo " Bringing up database, running migrations and loading data"
11
+ docker-compose up -d db
12
+ docker-compose run --rm --no-deps migrations yarn --frozen-lockfile
13
+ docker-compose run --rm --no-deps migrations yarn graphile-migrate reset --erase
14
+ docker-compose up -d migrations
15
+ # docker-compose run --rm --no-deps migrations yarn load
You can’t perform that action at this time.
0 commit comments