Skip to content

Commit 332b540

Browse files
committed
#9 add dockerfile
1 parent 47bfee1 commit 332b540

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.dockerignore
2+
.gitignore
3+
.git
4+
Dockerfile
5+
node_modules
6+
eslint-plugin/node_modules
7+
dist
8+
env
9+
coverage

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM node:14-alpine as deps
2+
RUN apk add --no-cache libc6-compat
3+
WORKDIR /app
4+
COPY yarn.lock package.json ./
5+
COPY eslint-plugin/yarn.lock ./eslint-plugin/
6+
COPY eslint-plugin/package.json ./eslint-plugin/
7+
RUN ls
8+
RUN cd eslint-plugin && yarn install --frozen-lockfile --silent && cd ../
9+
RUN yarn install --frozen-lockfile --silent
10+
11+
FROM node:14-alpine as builder
12+
WORKDIR /app
13+
COPY --from=deps /app/node_modules ./node_modules
14+
COPY . .
15+
RUN yarn build
16+
17+
FROM node:14-alpine as runner
18+
WORKDIR /app
19+
RUN addgroup -g 1001 -S nodejs
20+
RUN adduser -S nestjs -u 1001
21+
22+
COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist
23+
COPY --from=builder --chown=nestjs:nodejs /app/node_modules ./node_modules
24+
25+
ENV DB_ADDRESS=$DB_ADDRESS
26+
ENV DB_USER=$DB_USER
27+
ENV DB_PASSWORD=$DB_PASSWORD
28+
ENV DB_NAME=$DB_NAME
29+
ENV DB_PORT=$DB_PORT
30+
ENV JWT_SECRET=$JWT_SECRET
31+
ENV JWT_EXPIRES_IN=$JWT_EXPIRES_IN
32+
ENV PORT_API=$PORT_API
33+
ENV JWT_REFRESH_TOKEN_SECRET=$JWT_REFRESH_TOKEN_SECRET
34+
ENV JWT_REFRESH_TOKEN_EXPIRATION_TIME=$JWT_REFRESH_TOKEN_EXPIRATION_TIME
35+
36+
USER nestjs
37+
38+
EXPOSE 3000
39+
40+
CMD ["sh", "-c", "DB_ADDRESS=$DB_ADDRESS DB_USER=$DB_USER DB_PASSWORD=$DB_PASSWORD DB_NAME=$DB_NAME DB_PORT=$DB_PORT JWT_SECRET=$JWT_SECRET JWT_EXPIRES_IN=$JWT_EXPIRES_IN PORT_API=$PORT_API JWT_REFRESH_TOKEN_SECRET=$JWT_REFRESH_TOKEN_SECRET JWT_REFRESH_TOKEN_EXPIRATION_TIME=$JWT_REFRESH_TOKEN_EXPIRATION_TIME NODE_ENV=production node dist/main"]

0 commit comments

Comments
 (0)