-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
34 lines (24 loc) · 815 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
# This Dockerfile uses a multi-stage build. Only the first stage requires
# all dependencies, the final image will contain only the output files
# First stage: Build project
FROM node as build
# Copy files and install dependencies
COPY ./ /
RUN npm install
# Build project
RUN npm run build
# Second stage: Server to deliver files
FROM node:alpine
# Install http server
RUN npm install --global --no-save http-server
# Port 8080 can be used as non root
EXPOSE 8080
# Create user with home directory and no password
RUN adduser -Dh /public server
USER server
WORKDIR /public
# Copy files from first stage
COPY --from=build /index.html /public/
COPY --from=build /dist /public/dist
# Run server (-g will automatically serve the gzipped files if possible)
CMD ["/usr/local/bin/http-server", "-g", "/public"]