-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.development
More file actions
56 lines (41 loc) · 1.4 KB
/
Dockerfile.development
File metadata and controls
56 lines (41 loc) · 1.4 KB
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
48
49
50
51
52
53
54
55
56
# External build argument, passed in by --build-arg
ARG NODE_VERSION
################################ Build Stage ##################################
FROM node:${NODE_VERSION}-alpine AS builder
# Install dependencies
RUN apk add --no-cache make
# Copy the files required to build the app
COPY package*.json \
tsconfig.json \
tslint.json \
nodemon.json \
webpack.config.js \
Makefile \
.env \
/app/
COPY src/ /app/src
WORKDIR /app
RUN make production-bundle
################################ Final Stage ##################################
FROM node:${NODE_VERSION}-alpine AS final
# Remove yarn
RUN rm -rf /opt/yarn*
# External build arguments, passed in by --build-arg, with defaults
ARG COMPANY_NAME=company
ARG APP_NAME=app
# Used as a local shorthand, doesn't come from --build-arg
ARG DEPLOYMENT_DIR=/opt/$COMPANY_NAME/$APP_NAME
RUN mkdir -p $DEPLOYMENT_DIR
# Copy only the necessary files from the build stage
COPY --from=builder /app/package*.json \
/app/nodemon.json \
/app/tsconfig.json \
/app/webpack.config.js \
$DEPLOYMENT_DIR/
COPY --from=builder /app/build $DEPLOYMENT_DIR/build
COPY --from=builder /app/src/ $DEPLOYMENT_DIR/src
RUN chown -R node:node $DEPLOYMENT_DIR
USER node
WORKDIR $DEPLOYMENT_DIR
RUN npm i
CMD ["npm", "run", "watch"]