-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
47 lines (35 loc) · 1.61 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
FROM ubuntu:20.04 AS system-setup
# Env
ENV TZ=UTC
# Set the timezone in docker
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
################################################################################
FROM node:lts-alpine AS packages-installation
# Create Directory for the Container
WORKDIR /usr/src/organization/api
# Only copy the package.json and tsconfig.json file to work directory
COPY package.json .
COPY tsconfig.json .
RUN yarn install --silent --non-interactive && yarn cache clean
################################################################################
FROM node:lts-alpine AS api-build
WORKDIR /usr/src/organization/api
# Copy the package.json, tsconfig.json, node_modules and build files to work directory
COPY --from=packages-installation /usr/src/organization/api/package.json .
COPY --from=packages-installation /usr/src/organization/api/tsconfig.json .
COPY --from=packages-installation /usr/src/organization/api/node_modules node_modules
COPY ./src src
RUN yarn build && rm -rf src
################################################################################
FROM node:lts-alpine AS api-production-stage
WORKDIR /organization/api
ENV ENV_NAME production
ENV NODE_ENV production
ENV NODE_CONFIG_ENV production
COPY --from=packages-installation /usr/src/organization/api/package.json .
COPY --from=packages-installation /usr/src/organization/api/tsconfig.json .
COPY --from=packages-installation /usr/src/organization/api/node_modules ./node_modules
COPY --from=api-build /usr/src/organization/api/build ./build
# Start
CMD [ "node", "build/server.js" ]
EXPOSE 80