-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (37 loc) · 1.18 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
# Use a node base image
FROM node:20-slim as build
# Update apt-get and install necessary tools including OpenSSL
RUN apt-get update && apt-get install -y openssl
# Set the working directory in the Docker container
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies including Prisma CLI
RUN npm ci --verbose
# Install TypeScript globally
RUN npm install -g typescript
# Copy prisma schema
COPY prisma ./prisma/
# Generate Prisma client
RUN npx prisma generate
# Copy rest of the source code
COPY . .
# Compile TypeScript to JavaScript
RUN npm run build
# Install only production dependencies
RUN npm prune --production
# Runtime stage
FROM node:20-slim
# Set the working directory in the runtime container
WORKDIR /app
# Install OpenSSL in runtime
RUN apt-get update && apt-get install -y openssl
# Copy build files from the build stage
COPY --from=build /app/dist ./dist
COPY --from=build /app/package*.json ./
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/prisma ./prisma
# Expose port 3000 for the app
EXPOSE 3000
# Run migrations and then start the application
CMD npx prisma migrate deploy && node dist/main.js