2024-04-07 08:13:09 +02:00
|
|
|
# Use the official Bun image (Bun doesn't run well on Musl but this seems to work)
|
|
|
|
|
# See all versions at https://hub.docker.com/r/oven/bun/tags
|
2024-04-07 11:22:45 +02:00
|
|
|
FROM imbios/bun-node:1.1.2-current-debian as base
|
2023-11-20 03:05:07 +01:00
|
|
|
|
2024-04-07 08:13:09 +02:00
|
|
|
# Install dependencies into temp directory
|
|
|
|
|
# This will cache them and speed up future builds
|
2023-11-20 03:05:07 +01:00
|
|
|
FROM base AS install
|
|
|
|
|
|
2024-04-07 08:13:09 +02:00
|
|
|
# Install with --production (exclude devDependencies)
|
2023-12-09 02:00:02 +01:00
|
|
|
RUN mkdir -p /temp
|
|
|
|
|
COPY . /temp
|
|
|
|
|
WORKDIR /temp
|
2024-04-07 08:13:09 +02:00
|
|
|
RUN bun install --frozen-lockfile
|
2023-11-20 03:05:07 +01:00
|
|
|
|
2024-04-07 08:13:09 +02:00
|
|
|
FROM base as build
|
|
|
|
|
|
|
|
|
|
# Copy the project
|
|
|
|
|
RUN mkdir -p /temp
|
|
|
|
|
COPY . /temp
|
|
|
|
|
# Copy dependencies
|
|
|
|
|
COPY --from=install /temp/node_modules /temp/node_modules
|
2023-12-09 00:00:47 +01:00
|
|
|
# Build the project
|
2024-04-07 08:13:09 +02:00
|
|
|
WORKDIR /temp
|
2024-04-07 10:56:15 +02:00
|
|
|
RUN bunx --bun prisma generate
|
2024-04-07 08:13:09 +02:00
|
|
|
RUN bun run prod-build
|
2024-04-07 13:03:57 +02:00
|
|
|
COPY prisma /temp/dist
|
2024-04-07 15:14:51 +02:00
|
|
|
WORKDIR /temp/dist
|
|
|
|
|
# Add sharp
|
|
|
|
|
RUN bun add sharp
|
2023-12-09 00:00:47 +01:00
|
|
|
|
2023-11-20 03:05:07 +01:00
|
|
|
# copy production dependencies and source code into final image
|
2024-04-07 12:35:27 +02:00
|
|
|
# Alpine (musl) causes errors with Bun :(
|
|
|
|
|
FROM oven/bun:1.1.2-slim
|
2023-11-20 03:05:07 +01:00
|
|
|
|
|
|
|
|
# Create app directory
|
|
|
|
|
RUN mkdir -p /app
|
2024-04-07 08:13:09 +02:00
|
|
|
COPY --from=build /temp/dist /app/dist
|
2023-12-09 00:00:47 +01:00
|
|
|
COPY entrypoint.sh /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
|
|
|
|
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
|
2024-04-07 12:35:27 +02:00
|
|
|
ENTRYPOINT [ "/bin/bash", "/app/entrypoint.sh" ]
|
2023-11-28 02:47:39 +01:00
|
|
|
# Run migrations and start the server
|
2024-04-07 10:56:15 +02:00
|
|
|
CMD [ "start" ]
|