forked from webwhiz-ai/webwhiz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
38 lines (25 loc) · 900 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
###################
# BUILD FOR PRODUCTION
###################
FROM node:18-alpine As build
WORKDIR /usr/src/app
COPY --chown=node:node package*.json yarn.lock ./
RUN yarn install
COPY --chown=node:node . .
# Set NODE_ENV environment variable
ENV NODE_ENV production
# Run the build command which creates the production bundle
RUN yarn run build
# Remove the existing node_modules and install only production deps
RUN rm -rf node_modules && yarn install --production
USER node
###################
# PRODUCTION
###################
FROM node:18-alpine As production
# Copy the bundled code from the build stage to the production image
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist
COPY --chown=node:node .env.docker .env
# Start the server using the production build
CMD [ "node", "dist/main.js" ]