-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (39 loc) · 1.43 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# RUN apk add --no-cache bash
# RUN npm i -g @nestjs/cli typescript ts-node
# COPY package*.json /tmp/app/
# RUN cd /tmp/app && npm install
# COPY . /usr/src/app
# RUN cp -a /tmp/app/node_modules /usr/src/app
# COPY ./wait-for-it.sh /opt/wait-for-it.sh
# COPY ./startup.dev.sh /opt/startup.dev.sh
# RUN sed -i 's/\r//g' /opt/wait-for-it.sh
# RUN sed -i 's/\r//g' /opt/startup.dev.sh
# WORKDIR /usr/src/app
# RUN cp env-example .env
# RUN npm run build
# CMD ["/opt/startup.dev.sh"]
# Use the official Node.js 18 image as a base
FROM node:18.16.1-alpine
# Install bash for debugging purposes (optional)
RUN apk add --no-cache bash
# Install global Node.js packages for NestJS development
RUN npm i -g @nestjs/cli typescript ts-node
# Set the working directory inside the container
WORKDIR /usr/src/app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Copy the Prisma configuration and migration files
# This line copies the "prisma" directory from your project's root into the Docker container's working directory.
COPY prisma ./prisma/
# Install project dependencies
RUN npm install
# Copy the rest of the application code to the container
COPY . .
# Build your Nest.js application
RUN npm run build
# Expose the PORT environment variable (default to 4000 if not provided)
ARG PORT=4000
ENV PORT=$PORT
EXPOSE $PORT
# Start the Nest.js application using the start:prod script
CMD ["npm", "run", "start:prod"]