File tree 7 files changed +90
-30
lines changed
7 files changed +90
-30
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
- cd /usr/src /app
3
+ cd /home/node /app
4
4
5
5
yarn db:deploy
6
- yarn start:prod
6
+ dumb-init node dist/main.js
Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ node_modules
3
3
dist
4
4
* .tsbuildinfo
5
5
coverage
6
+ coverage-e2e
6
7
.dockerignore
7
8
Dockerfile
8
9
.git
9
10
.gitignore
10
11
. /test
12
+ docker-compose *
13
+ .docker /.yarn-cache
Original file line number Diff line number Diff line change 1
- FROM node:12
2
-
3
- WORKDIR /usr/src/app
4
-
1
+ FROM node:14-alpine AS build
2
+ WORKDIR /var/app
5
3
COPY package.json yarn.lock ./
6
-
7
- RUN yarn
8
-
4
+ RUN yarn install --frozen-lockfile
9
5
COPY . .
6
+ RUN yarn prisma:generate && \
7
+ yarn build
8
+ COPY src/i18n dist/i18n
10
9
11
- RUN yarn prisma:generate
12
-
13
- RUN yarn build
14
-
15
- EXPOSE 7100
16
-
17
- ENTRYPOINT [ "sh" , "./.docker/entrypoint.sh" ]
10
+ FROM node:14-alpine AS dependencies
11
+ WORKDIR /var/app
12
+ COPY package.json yarn.lock ./
13
+ RUN yarn install --production=true --frozen-lockfile
14
+ COPY --from=build /var/app/node_modules/.prisma /var/app/node_modules/.prisma
15
+ COPY --from=build /var/app/node_modules/prisma /var/app/node_modules/prisma
16
+
17
+ FROM node:14-alpine AS runtime
18
+ ARG VERSION="1.0.0"
19
+ ENV VERSION $VERSION
20
+ ENV NODE_ENV production
21
+ ENV TZ America/Sao_Paulo
22
+ RUN apk add dumb-init
23
+ USER node
24
+ EXPOSE 4000
25
+ COPY --chown=node:node --from=dependencies /var/app/node_modules /home/node/app/node_modules/
26
+ COPY .docker/entrypoint.sh /home/node/app
27
+ COPY prisma /home/node/app/prisma
28
+ COPY package.json /home/node/app/package.json
29
+ COPY --chown=node:node --from=build /var/app/dist /home/node/app/dist/
30
+
31
+ ENTRYPOINT [ "sh" , "/home/node/app/entrypoint.sh" ]
Original file line number Diff line number Diff line change 1
- FROM node:12.14-alpine3.11
2
-
3
- RUN apk add --no-cache bash
4
-
5
- RUN touch /root/.bashrc | echo "PS1='\w\$ '" >> /root/.bashrc
1
+ FROM node:14-alpine
6
2
7
3
WORKDIR /usr/src/app
8
4
9
- EXPOSE 7100
5
+ COPY . .
6
+
7
+ EXPOSE 4000
10
8
11
9
ENTRYPOINT [ "sh", "./.docker/entrypoint.dev.sh" ]
Original file line number Diff line number Diff line change
1
+ version : ' 3.7'
2
+
3
+ services :
4
+ app :
5
+ build :
6
+ context : .
7
+ dockerfile : Dockerfile.dev
8
+ container_name : template-api-dev
9
+ image : template-api-dev
10
+ platform : linux/amd64
11
+ ports :
12
+ - ' 4000:4000'
13
+ volumes :
14
+ - .:/usr/src/app
15
+ networks :
16
+ - ' app-network'
17
+ depends_on :
18
+ - db
19
+ environment :
20
+ - DATABASE_URL=postgresql://postgres:postgres@db:5432/template-api?schema=public
21
+
22
+ db :
23
+ image : postgres:latest
24
+ restart : unless-stopped
25
+ volumes :
26
+ - postgres-data:/var/lib/postgresql/data
27
+ ports :
28
+ - ' 5435:5432'
29
+ environment :
30
+ POSTGRES_PASSWORD : postgres
31
+ POSTGRES_USER : postgres
32
+ POSTGRES_DB : postgres
33
+ networks :
34
+ - ' app-network'
35
+
36
+ networks :
37
+ app-network :
38
+ driver : bridge
39
+
40
+ volumes :
41
+ postgres-data :
Original file line number Diff line number Diff line change 1
- version : ' 3'
1
+ version : ' 3.7 '
2
2
3
3
services :
4
4
test_db :
Original file line number Diff line number Diff line change 1
- version : ' 3'
1
+ version : ' 3.7 '
2
2
3
3
services :
4
4
app :
5
5
build :
6
6
context : .
7
- dockerfile : Dockerfile.dev
8
- entrypoint : ./.docker/entrypoint.dev.sh
9
- container_name : template-app
7
+ dockerfile : Dockerfile
8
+ container_name : template-api
9
+ image : template-api
10
+ # Uncomment this line in case you are in M1
11
+ # platform: linux/amd64
10
12
ports :
11
- - ' 7100:7100'
12
- volumes :
13
- - .:/usr/src/app
13
+ - ' 4000:4000'
14
14
networks :
15
15
- ' app-network'
16
16
depends_on :
17
17
- db
18
+ environment :
19
+ - NODE_ENV=development
20
+ - PORT=4000
21
+ - DATABASE_URL=postgresql://postgres:postgres@db:5432/template-api?schema=public
18
22
19
23
db :
20
24
image : postgres:latest
You can’t perform that action at this time.
0 commit comments