zipline/Dockerfile

76 lines
2.5 KiB
Text
Raw Permalink Normal View History

2023-01-26 18:58:22 -05:00
# Use the Prisma binaries image as the first stage
2023-02-26 22:46:27 -05:00
FROM ghcr.io/diced/prisma-binaries:4.10.x as prisma
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
2023-01-28 13:28:29 -05:00
WORKDIR /zipline
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
2023-02-25 23:36:05 -05:00
COPY public ./public
2023-01-26 18:58:22 -05:00
FROM base as builder
2023-01-26 18:58:22 -05:00
COPY .yarn ./.yarn
COPY package*.json ./
COPY yarn*.lock ./
COPY .yarnrc.yml ./
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
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
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
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
2023-02-18 13:02:40 -05:00
# Install the necessary packages
RUN apk add --no-cache perl procps tini
2023-01-26 18:58:22 -05:00
COPY --from=builder /prisma-engines /prisma-engines
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
2023-01-26 18:58:22 -05:00
# Copy only the necessary files from the previous stage
2023-01-28 13:28:29 -05:00
COPY --from=builder /zipline/dist ./dist
COPY --from=builder /zipline/.next ./.next
COPY --from=builder /zipline/package.json ./package.json
2023-01-28 13:28:29 -05:00
COPY --from=builder /zipline/node_modules ./node_modules
COPY --from=builder /zipline/node_modules/.prisma/client ./node_modules/.prisma/client
COPY --from=builder /zipline/node_modules/@prisma/client ./node_modules/@prisma/client
2021-06-23 13:20:20 -05:00
# Copy Startup Script
COPY docker-entrypoint.sh /zipline
2023-02-18 13:02:40 -05:00
# Make Startup Script Executable
RUN chmod a+x /zipline/docker-entrypoint.sh && rm -rf /zipline/src
2023-02-18 13:02:40 -05:00
# Set the entrypoint to the startup script
ENTRYPOINT ["tini", "--", "/zipline/docker-entrypoint.sh"]