forked from coralproject/talk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (32 loc) · 1.33 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
FROM node:14-alpine
ENV NODE_OPTIONS=--max-old-space-size=8192
# Install build dependancies.
RUN apk --no-cache add git python3
RUN npm install -g [email protected]
# Create app directory.
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Bundle application source.
COPY . /usr/src/app
# Store the current git revision.
ARG REVISION_HASH
RUN mkdir -p dist/core/common/__generated__ && \
echo "{\"revision\": \"${REVISION_HASH}\"}" > dist/core/common/__generated__/revision.json
# Run all application code and dependancy setup as a non-root user:
# SEE: https://github.com/nodejs/docker-node/blob/a2eb9f80b0fd224503ee2678867096c9e19a51c2/docs/BestPractices.md#non-root-user
RUN chown -R node /usr/src/app
USER node
# Node alpine image does not include ssh. This is a workaround for https://github.com/npm/cli/issues/2610.
RUN git config --global url."https://github.com/".insteadOf ssh://[email protected]/ && \
git config --global url."https://".insteadOf ssh://
# Install build static assets and clear caches.
RUN npm ci && \
npm run build && \
npm prune --production
# Setup the environment
ENV NODE_ENV production
ENV PORT 5000
EXPOSE 5000
# Run the node process directly instead of using `npm run start`:
# SEE: https://github.com/nodejs/docker-node/blob/a2eb9f80b0fd224503ee2678867096c9e19a51c2/docs/BestPractices.md#cmd
CMD ["node", "dist/index.js"]