server/Dockerfile

50 lines
1.5 KiB
Docker
Raw Normal View History

2023-11-20 03:05:07 +01:00
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
2024-03-11 04:29:13 +01:00
FROM oven/bun:1.0.30-alpine as base
2023-11-20 03:05:07 +01:00
WORKDIR /usr/src/app
RUN apk add vips
2023-11-27 06:30:57 +01:00
# Required for Prisma to work
COPY --from=node:18-alpine /usr/local/bin/node /usr/local/bin/node
2023-11-20 03:05:07 +01:00
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
# install with --production (exclude devDependencies)
RUN mkdir -p /temp
COPY . /temp
WORKDIR /temp
RUN bun install --frozen-lockfile --production.
2023-11-20 03:05:07 +01:00
# Build Vite in pages
RUN bunx --bun vite build pages
# Build the project
2023-12-09 04:15:59 +01:00
RUN bun build --entrypoints ./index.ts ./prisma.ts ./cli.ts --outdir dist --target bun --splitting --minify --external bullmq --external @prisma/client
RUN mkdir ./dist/pages
RUN cp -r ./pages/dist ./dist/pages
WORKDIR /temp/dist
2023-11-20 03:05:07 +01:00
# copy production dependencies and source code into final image
FROM base AS release
# Create app directory
RUN mkdir -p /app
COPY --from=install /temp/dist /app/dist
COPY entrypoint.sh /app
2023-11-20 03:05:07 +01:00
2023-12-07 18:45:07 +01:00
2023-11-27 06:30:57 +01:00
LABEL org.opencontainers.image.authors "Gaspard Wierzbinski (https://cpluspatch.dev)"
LABEL org.opencontainers.image.source "https://github.com/lysand-org/lysand"
LABEL org.opencontainers.image.vendor "Lysand Org"
LABEL org.opencontainers.image.licenses "AGPL-3.0"
LABEL org.opencontainers.image.title "Lysand Server"
LABEL org.opencontainers.image.description "Lysand Server docker image"
2023-11-20 03:05:07 +01:00
2023-11-27 23:08:18 +01:00
# CD to app
WORKDIR /app
2023-11-28 02:47:39 +01:00
ENV NODE_ENV=production
# Run migrations and start the server
ENTRYPOINT [ "./entrypoint.sh" "start" ]