project-knedita/Dockerfile

38 lines
1 KiB
Text
Raw Normal View History

2024-10-25 18:06:25 +00:00
FROM oven/bun:latest AS base
2024-01-31 12:58:50 +00:00
WORKDIR /usr/src/app
2024-10-25 18:06:25 +00:00
# Install deps into tmp dir
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb docker.env /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile
# Install without dev deps
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
COPY .husky/ /temp/prod/.husky/
RUN bun install husky -g
RUN cd /temp/prod && bun install --frozen-lockfile --production
# Copy node_modules from temp directory
FROM base AS prerelase
COPY --from=install /temp/dev/node_modules node_modules
COPY --from=install /temp/dev/docker.env .env
COPY . .
2024-01-31 12:58:50 +00:00
ENV NODE_ENV production
2024-10-25 18:06:25 +00:00
RUN bun migrate:deploy
2024-01-31 12:58:50 +00:00
2024-10-25 18:06:25 +00:00
RUN bun run build
2023-07-20 11:15:29 +00:00
2024-10-25 18:06:25 +00:00
# Copy production deps
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelase /usr/src/app/dist dist
COPY --from=prerelase /usr/src/app/prisma prisma
COPY --from=prerelase /usr/src/app/.husky ./.husky
COPY --from=prerelase /usr/src/app/.env ./.env
COPY --from=prerelase /usr/src/app/package*.json ./
2023-06-20 20:05:15 +00:00
2024-10-25 18:06:25 +00:00
CMD [ "bun", "dist/main.js" ]