remix-demo
react router (remix) demo
git clone https://9o.is/git/remix-demo.git
Dockerfile
(1113B)
1 # base node image
2 FROM node:16-bullseye-slim as base
3
4 # set for base and all layer that inherit from it
5 ENV NODE_ENV production
6
7 # Install openssl for Prisma
8 RUN apt-get update && apt-get install -y openssl
9
10 # Install all node_modules, including dev dependencies
11 FROM base as deps
12
13 WORKDIR /myapp
14
15 ADD package.json package-lock.json .npmrc ./
16 RUN npm install --production=false
17
18 # Setup production node_modules
19 FROM base as production-deps
20
21 WORKDIR /myapp
22
23 COPY --from=deps /myapp/node_modules /myapp/node_modules
24 ADD package.json package-lock.json .npmrc ./
25 RUN npm prune --production
26
27 # Build the app
28 FROM base as build
29
30 WORKDIR /myapp
31
32 COPY --from=deps /myapp/node_modules /myapp/node_modules
33
34 ADD prisma .
35 RUN npx prisma generate
36
37 ADD . .
38 RUN npm run build
39
40 # Finally, build the production image with minimal footprint
41 FROM base
42
43 WORKDIR /myapp
44
45 COPY --from=production-deps /myapp/node_modules /myapp/node_modules
46 COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma
47
48 COPY --from=build /myapp/build /myapp/build
49 COPY --from=build /myapp/public /myapp/public
50 ADD . .
51
52 CMD ["npm", "start"]