37 lines
1005 B
Docker
37 lines
1005 B
Docker
# Build stage for Backend
|
|
FROM docker.arvancloud.ir/library/node:22-alpine AS builder
|
|
|
|
# Use ArvanCloud Alpine mirror to fix TLS/timeout issues
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirror.arvancloud.ir/g' /etc/apk/repositories && \
|
|
apk add --no-cache openssl
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
# Using mirror for npm as well
|
|
RUN npm config set registry https://registry.npmmirror.com
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM docker.arvancloud.ir/library/node:22-alpine
|
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirror.arvancloud.ir/g' /etc/apk/repositories && \
|
|
apk add --no-cache openssl
|
|
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
RUN npm config set registry https://registry.npmmirror.com
|
|
RUN npm ci --only=production
|
|
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder /app/node_modules/@prisma/client ./node_modules/@prisma/client
|
|
|
|
EXPOSE 3000
|
|
USER node
|
|
CMD ["node", "dist/main"]
|