-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (36 loc) · 1.36 KB
/
Dockerfile
File metadata and controls
50 lines (36 loc) · 1.36 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
# Build stage
FROM node:22-alpine AS builder
# Use alpine-based image and install only necessary dependencies
RUN apk add --no-cache openssl
WORKDIR /app
# Only needed for prisma build
ARG DATABASE_URL
# Copy only necessary files for dependency installation
COPY package.json yarn.lock ./
COPY prisma ./prisma/
RUN yarn install --frozen-lockfile \
&& yarn prisma:generate \
&& yarn cache clean
# Copy source files and build
COPY . .
RUN yarn run build
# Production stage
FROM node:22-alpine
LABEL maintainer="FAIR Data Innovations Hub <contact@fairdataihub.org>" \
description="A web application for the FAIR Data Innovations Hub"
# Busybox is used netcat for waiting for Postgres to be ready
RUN apk add --no-cache openssl busybox-extras
WORKDIR /app
# Copy only the necessary files from builder stage
# COPY --from=builder /app/package.json ./
COPY --from=builder /app/.output ./
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
# Copy the Prisma schema & migrations, so `prisma migrate deploy` can see them
COPY --from=builder /app/prisma ./prisma
# Copy our startup script and make it executable
COPY scripts/start.sh /app/scripts/start.sh
RUN chmod +x /app/scripts/start.sh
EXPOSE 3000
# Run startup script that runs migrations before starting the app
CMD ["/app/scripts/start.sh"]