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
|
2023-11-27 06:30:57 +01:00
|
|
|
FROM oven/bun:1.0.14-alpine as base
|
2023-11-20 03:05:07 +01:00
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
2023-11-27 06:30:57 +01:00
|
|
|
RUN apk add vips-dev
|
|
|
|
|
# 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
|
|
|
|
|
RUN mkdir -p /temp/dev
|
|
|
|
|
COPY package.json bun.lockb /temp/dev/
|
|
|
|
|
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
|
|
|
|
|
|
|
|
# install with --production (exclude devDependencies)
|
|
|
|
|
RUN mkdir -p /temp/prod
|
|
|
|
|
COPY package.json bun.lockb /temp/prod/
|
2023-11-27 06:30:57 +01:00
|
|
|
RUN cd /temp/prod && bun install --frozen-lockfile --production.
|
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/prod/node_modules /app/node_modules
|
2023-11-27 06:30:57 +01:00
|
|
|
COPY . /app
|
2023-11-20 03:05: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
|
|
|
|
|
|
|
|
# run the app
|
|
|
|
|
USER bun
|
2023-11-27 06:30:57 +01:00
|
|
|
RUN bunx prisma generate
|
|
|
|
|
# Remove Node
|
|
|
|
|
USER root
|
|
|
|
|
RUN rm /usr/local/bin/node
|
|
|
|
|
USER bun
|
2023-11-20 03:05:07 +01:00
|
|
|
ENTRYPOINT [ "bun", "run", "index.ts" ]
|