Skip to content

Commit 9d5a7b1

Browse files
authored
Dockerfile Updates (#399)
* updated GH flow * leaned dockerfile * reverted compose prod.yml
1 parent bb572a6 commit 9d5a7b1

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

Dockerfile

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
FROM node:18.15.0-alpine AS base
22

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
56

67
# Set the working directory
78
WORKDIR /app
89

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
1410

1511
# Copy package.json and yarn.lock files
1612
COPY package*.json yarn*.lock ./
1713

1814
# Copy the entire project directory
1915
COPY . .
2016

21-
RUN npm install -g nodemon
22-
2317
# Install dependencies for both development and production
2418
RUN yarn install --frozen-lockfile --network-timeout 1000000
2519

2620
WORKDIR /app/src/https
2721

2822
RUN openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 \
2923
-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
3326

3427
WORKDIR /app
3528

@@ -43,35 +36,27 @@ FROM base AS local
4336

4437
EXPOSE 3005
4538
ENV NODE_ENV="local"
39+
RUN npm install -g nodemon
4640

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" ]
4845

4946
##############################
5047
##############################
5148

5249
# Production Node Modules stage
53-
FROM node:18.15.0-alpine AS prod-dependencies
50+
FROM base AS prod-dependencies
5451

55-
# Install build dependencies
56-
RUN apk add --no-cache g++ make py3-pip
5752
WORKDIR /app
5853

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-
6654
# Build the project
6755
RUN yarn build && \
6856
yarn copy-files && \
6957
rm -rf node_modules && \
7058
yarn install --production=true --frozen-lockfile --network-timeout 1000000
7159

72-
# Clean up build dependencies
73-
RUN apk del g++ make py3-pip
74-
7560
##############################
7661
##############################
7762

@@ -87,7 +72,9 @@ RUN apk add --no-cache tini
8772

8873
# Set the working directory
8974
WORKDIR /app
90-
ENV NODE_ENV="production"
75+
ENV NODE_ENV="production" \
76+
PATH=/app/node_modules/.bin:$PATH
77+
9178
EXPOSE 3005
9279

9380
# Copy package.json and yarn.lock files
@@ -101,9 +88,6 @@ COPY --from=prod-dependencies /app/node_modules ./node_modules
10188
COPY --from=prod-dependencies /app/dist ./dist
10289
COPY --from=base /app/src/https ./dist/https
10390

104-
# Add the node_modules/.bin directory to the PATH
105-
ENV PATH /app/node_modules/.bin:$PATH
106-
10791
# Use tini as entrypoint to handle killing processes
10892
ENTRYPOINT ["/sbin/tini", "--"]
10993
CMD [ "yarn", "start"]

0 commit comments

Comments
 (0)