-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (37 loc) · 1 KB
/
Dockerfile
File metadata and controls
51 lines (37 loc) · 1 KB
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
# Use Node.js LTS slim image
FROM node:20-slim
# Set working directory
WORKDIR /usr/src/app
# Install OpenSSL and other required dependencies for Prisma
RUN apt-get update && apt-get install -y openssl
# Install pnpm globally
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy configuration files first
COPY pnpm-lock.yaml ./
COPY package.json ./
COPY .babelrc ./
COPY jsconfig.json ./
COPY prisma ./prisma/
# Install all dependencies (including devDependencies for building)
RUN pnpm install
# Generate Prisma Client
RUN pnpm dlx prisma generate
# Copy source code
COPY . .
# Build using Babel
RUN pnpm run build
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3001
# Expose the port the app runs on
EXPOSE 3001
# Create a script to handle startup tasks
RUN pnpm dlx prisma migrate deploy
# Remove dev dependencies after build
RUN pnpm prune --prod
# Switch to non-root user
USER node
# Start the application
CMD ["pnpm", "start"]