-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (43 loc) · 1.47 KB
/
Dockerfile
File metadata and controls
54 lines (43 loc) · 1.47 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
FROM node:carbon-alpine AS build-env
# Upgrade OS dependencies
RUN apk update && apk upgrade
# Set the working directory to the location of our app
WORKDIR /opt/app
#Timezone
RUN apk add tzdata && cp /usr/share/zoneinfo/UTC /etc/localtime
RUN echo "UTC" > /etc/timezone
RUN date && apk del tzdata
# Copy Node.js App dependency manifest
COPY package.json ./package.json
# Use exactly the same versions as in local environment
COPY package-lock.json ./package-lock.json
# Install Node.js dependencies
RUN npm install
# RUN mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/
# Copy our app from the hard drive to the working direcotry in the docker image
COPY ./ ./
# Build the App inside the image
RUN npm run build
##################
# Production Build
FROM node:carbon-alpine
# Upgrade OS dependencies
RUN apk update && apk upgrade
#Timezone
RUN apk add tzdata && cp /usr/share/zoneinfo/UTC /etc/localtime
RUN echo "UTC" > /etc/timezone
RUN date && apk del tzdata
# Install Nginx for app serving
RUN apk add nginx
RUN adduser -D -g 'www' www
RUN mkdir /www
RUN chown -R www:www /var/lib/nginx
RUN chown -R www:www /www
COPY nginx.conf /etc/nginx/nginx.conf
# Default port for this App Skeleton, will be exposed when -P specified
EXPOSE 80
# Copy from build stage
WORKDIR /www
COPY --from=build-env /opt/app/www .
# using array notation causes node to be PID1 and will not exit properly. Without the array notation the shell forwards the sigterm correctly.
CMD ["nginx", "-g", "daemon off;"]