-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
40 lines (29 loc) · 964 Bytes
/
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
# Base image
FROM alpine:3.7
# Update system and install dependencies (make gcc g++ and python are the equivalent for the build-essential package in the previous Dockerfile)
RUN apk update && \
apk add nodejs make gcc g++ python
# Create and define work directory
WORKDIR /code
# Copy required files
COPY ./ /code
# Install required npm packages
RUN npm set progress=false && \
npm install --silent
# Build application
RUN npm run build
# NEW STUFF: clean extra system and npm packages, remove useless files
RUN npm prune --production
RUN apk del make gcc g++ python && \
rm -rf /var/cache/apk/*
RUN rm -rf /code/dockerfiles /code/tsconfig.json
# Create dedicated user to not run the application as root (security best practice)
RUN adduser -D -h /code -u 5000 myuser && \
chown -R myuser:myuser /code
USER myuser
# Expose application port
EXPOSE 8080
# Define entrypoint
ENTRYPOINT ["npm", "run"]
# Define default command
CMD ["start"]