2023-01-26 18:58:22 -05:00
|
|
|
# Use the Prisma binaries image as the first stage
|
2023-01-14 18:25:36 -05:00
|
|
|
FROM ghcr.io/diced/prisma-binaries:4.8.x as prisma
|
2022-06-24 13:27:35 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Use Alpine Linux as the second stage
|
|
|
|
FROM node:18-alpine3.16 as base
|
2021-06-23 13:20:20 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Set the working directory
|
|
|
|
WORKDIR /app
|
2021-09-17 22:39:20 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Copy the necessary files from the project
|
|
|
|
COPY prisma ./prisma
|
|
|
|
COPY src ./src
|
|
|
|
COPY next.config.js ./next.config.js
|
|
|
|
COPY tsup.config.ts ./tsup.config.ts
|
|
|
|
COPY tsconfig.json ./tsconfig.json
|
|
|
|
COPY mimes.json ./mimes.json
|
|
|
|
|
|
|
|
FROM base as builder
|
2022-02-19 23:17:02 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
COPY .yarn ./.yarn
|
|
|
|
COPY package*.json ./
|
|
|
|
COPY yarn*.lock ./
|
|
|
|
COPY .yarnrc.yml ./
|
2022-02-19 23:17:02 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Copy the prisma binaries from prisma stage
|
2022-06-24 19:01:23 -05:00
|
|
|
COPY --from=prisma /prisma-engines /prisma-engines
|
2022-06-24 13:27:35 -05:00
|
|
|
ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \
|
|
|
|
PRISMA_MIGRATION_ENGINE_BINARY=/prisma-engines/migration-engine \
|
|
|
|
PRISMA_INTROSPECTION_ENGINE_BINARY=/prisma-engines/introspection-engine \
|
|
|
|
PRISMA_FMT_BINARY=/prisma-engines/prisma-fmt \
|
|
|
|
PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
|
2023-01-26 18:58:22 -05:00
|
|
|
PRISMA_CLIENT_ENGINE_TYPE=binary \
|
|
|
|
ZIPLINE_DOCKER_BUILD=true \
|
|
|
|
NEXT_TELEMETRY_DISABLED=1
|
2022-06-24 13:27:35 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Install production dependencies then temporarily save
|
|
|
|
RUN yarn workspaces focus --production --all
|
|
|
|
RUN cp -RL node_modules /tmp/node_modules
|
2022-06-21 00:29:33 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Install the dependencies
|
|
|
|
RUN yarn install --immutable
|
2022-02-12 23:35:36 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Run the build
|
2021-06-23 13:20:20 -05:00
|
|
|
RUN yarn build
|
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Use Alpine Linux as the final image
|
|
|
|
FROM base
|
2021-06-23 13:20:20 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
RUN apk add --no-cache perl procps
|
|
|
|
|
|
|
|
# Set the working directory
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY --from=builder /prisma-engines /prisma-engines
|
2022-06-24 13:27:35 -05:00
|
|
|
ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \
|
|
|
|
PRISMA_MIGRATION_ENGINE_BINARY=/prisma-engines/migration-engine \
|
|
|
|
PRISMA_INTROSPECTION_ENGINE_BINARY=/prisma-engines/introspection-engine \
|
|
|
|
PRISMA_FMT_BINARY=/prisma-engines/prisma-fmt \
|
|
|
|
PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
|
2023-01-26 18:58:22 -05:00
|
|
|
PRISMA_CLIENT_ENGINE_TYPE=binary \
|
|
|
|
NEXT_TELEMETRY_DISABLED=1
|
2022-02-19 23:17:02 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Copy only the necessary files from the previous stage
|
|
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
COPY --from=builder /app/.next ./.next
|
|
|
|
COPY --from=builder /app/package.json ./package.json
|
2022-02-19 23:17:02 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
COPY --from=builder /tmp/node_modules ./node_modules
|
|
|
|
COPY --from=builder /app/node_modules/.prisma/client ./node_modules/.prisma/client
|
|
|
|
COPY --from=builder /app/node_modules/@prisma/client ./node_modules/@prisma/client
|
2021-06-23 13:20:20 -05:00
|
|
|
|
2023-01-26 18:58:22 -05:00
|
|
|
# Run the application
|
|
|
|
CMD ["node", "--enable-source-maps", "dist/index.js"]
|