-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (31 loc) · 891 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
FROM node:14.18-alpine3.12 as node
# Builder stage
FROM node as builder
# Use /app as the CWD
WORKDIR /app
# Copy package.json and package-lock.json to /app
COPY package*.json ./
# Install all dependencies
RUN npm install
# https://community.fly.io/t/fly-secrets-not-populated-during-build/659
ARG STRIPE_PUBLISH_KEY
ENV STRIPE_PUBLISH_KEY=${STRIPE_PUBLISH_KEY}
# Copy the rest of the code
COPY . .
RUN npm run build
# Final stage
FROM node as final
# Prepare a destination directory for js files
RUN mkdir -p /app/build
# Use /app as CWD
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install only production dependencies
RUN npm i --only=production
# Copy transpiled js from "builder" stage into the "final" image
COPY --from=builder /app/build ./build
COPY ./static-server.js ./static-server.js
# Open desired port
EXPOSE 8080
CMD ["npm", "start"]