scratchmasterj21 commited on
Commit
4479f12
·
verified ·
1 Parent(s): 27952ec

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -0
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Base Node image
2
+ FROM node:20-bookworm-slim AS base
3
+
4
+ # Set for base and all layer that inherit from it
5
+ ENV PORT="8080"
6
+ ENV NODE_ENV="production"
7
+ ARG DEBIAN_FRONTEND="noninteractive"
8
+ WORKDIR /src
9
+
10
+ # Install openssl for Prisma
11
+ RUN apt-get update && \
12
+ apt-get install -y openssl && \
13
+ rm -rf /var/lib/apt/lists/*
14
+
15
+
16
+ # Install all node_modules, including dev dependencies
17
+ FROM base AS deps
18
+
19
+ ADD package.json .
20
+ RUN npm install --include=dev
21
+
22
+ # Build the app and setup production node_modules
23
+ FROM base AS build
24
+
25
+ COPY --from=deps /src/node_modules /src/node_modules
26
+
27
+ ADD . .
28
+
29
+ RUN npx prisma generate
30
+ RUN npm run build
31
+ RUN npm prune --omit=dev
32
+
33
+ # Finally, build the production image with minimal footprint
34
+ FROM base AS release
35
+
36
+ COPY --from=build /src/node_modules /src/node_modules
37
+ COPY --from=build /src/app/database /src/app/database
38
+ COPY --from=build /src/build /src/build
39
+ COPY --from=build /src/package.json /src/package.json
40
+ COPY --from=build /src/start.sh /src/start.sh
41
+
42
+ RUN chmod +x /src/start.sh
43
+
44
+ ENTRYPOINT [ "/src/start.sh" ]