1
1
FROM node:18.15.0-alpine AS base
2
2
3
- # Install tini
4
- RUN apk add --no-cache tini
3
+ # Install tini & build dependencies
4
+ RUN apk add --no-cache tini && \
5
+ apk --no-cache --virtual build-dependencies add g++ make py3-pip openssl
5
6
6
7
# Set the working directory
7
8
WORKDIR /app
8
9
9
- # Use tini as entrypoint to handle killing processes
10
- ENTRYPOINT ["/sbin/tini" , "--" ]
11
-
12
- # Install build dependencies
13
- RUN apk --no-cache --virtual build-dependencies add g++ make py3-pip openssl
14
10
15
11
# Copy package.json and yarn.lock files
16
12
COPY package*.json yarn*.lock ./
17
13
18
14
# Copy the entire project directory
19
15
COPY . .
20
16
21
- RUN npm install -g nodemon
22
-
23
17
# Install dependencies for both development and production
24
18
RUN yarn install --frozen-lockfile --network-timeout 1000000
25
19
26
20
WORKDIR /app/src/https
27
21
28
22
RUN openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 \
29
23
-subj "/C=US/ST=State/L=City/O=Organization/OU=Unit/CN=localhost" \
30
- -passout pass:thirdweb-engine
31
-
32
- RUN chmod 600 key.pem cert.pem
24
+ -passout pass:thirdweb-engine && \
25
+ chmod 600 key.pem cert.pem
33
26
34
27
WORKDIR /app
35
28
@@ -43,35 +36,27 @@ FROM base AS local
43
36
44
37
EXPOSE 3005
45
38
ENV NODE_ENV="local"
39
+ RUN npm install -g nodemon
46
40
47
- CMD [ "sh" , "-c" ,"yarn prisma:setup:dev && yarn dev" ]
41
+ # Use tini as entrypoint to handle killing processes
42
+ ENTRYPOINT ["/sbin/tini" , "--" ]
43
+
44
+ CMD [ "sh" , "-c" ,"yarn prisma:setup:dev && yarn dev:run" ]
48
45
49
46
# #############################
50
47
# #############################
51
48
52
49
# Production Node Modules stage
53
- FROM node:18.15.0-alpine AS prod-dependencies
50
+ FROM base AS prod-dependencies
54
51
55
- # Install build dependencies
56
- RUN apk add --no-cache g++ make py3-pip
57
52
WORKDIR /app
58
53
59
- # Copy package.json and yarn.lock files
60
- COPY package*.json yarn*.lock ./
61
-
62
- # Copy the entire project directory
63
- COPY . .
64
- COPY --from=base /app/node_modules ./node_modules
65
-
66
54
# Build the project
67
55
RUN yarn build && \
68
56
yarn copy-files && \
69
57
rm -rf node_modules && \
70
58
yarn install --production=true --frozen-lockfile --network-timeout 1000000
71
59
72
- # Clean up build dependencies
73
- RUN apk del g++ make py3-pip
74
-
75
60
# #############################
76
61
# #############################
77
62
@@ -87,7 +72,9 @@ RUN apk add --no-cache tini
87
72
88
73
# Set the working directory
89
74
WORKDIR /app
90
- ENV NODE_ENV="production"
75
+ ENV NODE_ENV="production" \
76
+ PATH=/app/node_modules/.bin:$PATH
77
+
91
78
EXPOSE 3005
92
79
93
80
# Copy package.json and yarn.lock files
@@ -101,9 +88,6 @@ COPY --from=prod-dependencies /app/node_modules ./node_modules
101
88
COPY --from=prod-dependencies /app/dist ./dist
102
89
COPY --from=base /app/src/https ./dist/https
103
90
104
- # Add the node_modules/.bin directory to the PATH
105
- ENV PATH /app/node_modules/.bin:$PATH
106
-
107
91
# Use tini as entrypoint to handle killing processes
108
92
ENTRYPOINT ["/sbin/tini" , "--" ]
109
93
CMD [ "yarn" , "start" ]
0 commit comments