-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (34 loc) · 946 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
39
40
41
42
43
44
45
46
# ? Production Stage
FROM node:lts-slim as Runner
# Get environment variable for app port with fallback to 3000
ARG PORT=3000
ARG VERCEL_URL="http://localhost:3000"
ARG DATABASE_HOST="localhost"
ARG DATABASE_USERNAME="root"
ARG DATABASE_PASSWORD="root"
# Set environment variable for app port
ENV PORT=$PORT
ENV VERCEL_URL=$VERCEL_URL
ENV DATABASE_HOST=$DATABASE_HOST
ENV DATABASE_USERNAME=$DATABASE_USERNAME
ENV DATABASE_PASSWORD=$DATABASE_PASSWORD
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Copy bun lockfile if exists
COPY pnpm-lock.yaml ./
# Install pnpm globally
RUN npm install -g pnpm@latest
# Install dependencies
RUN pnpm install
# Copy source code
COPY . .
# Build app
RUN NODE_ENV="production" pnpm build
# Remove dev dependencies
RUN pnpm prune --prod
# Expose port based on environment variable or ARG
EXPOSE $PORT
# Run app
CMD ["pnpm", "container:start"]