server/Dockerfile

56 lines
1.6 KiB
Text
Raw Normal View History

2024-04-06 20:13:09 -10: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-06 23:22:45 -10:00
FROM imbios/bun-node:1.1.2-current-debian as base
2024-04-06 20:13:09 -10: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
FROM base as build
2023-11-19 16:05:07 -10:00
2024-04-06 20:13:09 -10:00
# Copy the project
RUN mkdir -p /temp
COPY . /temp
2024-04-06 20:13:09 -10:00
# Copy dependencies
COPY --from=install /temp/node_modules /temp/node_modules
# Build the project
2024-04-06 20:13:09 -10:00
WORKDIR /temp
2024-04-06 22:56:15 -10:00
RUN bunx --bun prisma generate
2024-04-06 20:13:09 -10:00
RUN bun run prod-build
2024-04-07 01:03:57 -10:00
COPY prisma /temp/dist
2024-04-07 03:14:51 -10:00
WORKDIR /temp/dist
2023-11-19 16:05:07 -10:00
# copy production dependencies and source code into final image
2024-04-07 00:35:27 -10:00
# Alpine (musl) causes errors with Bun :(
FROM oven/bun:1.1.2-slim
2023-11-19 16:05:07 -10:00
2024-04-07 03:55:38 -10:00
# Install libvips
RUN apt-get update && apt-get install -y libvips
2023-11-19 16:05:07 -10:00
# Create app directory
RUN mkdir -p /app
2024-04-06 20:13:09 -10:00
COPY --from=build /temp/dist /app/dist
2024-04-07 03:53:52 -10:00
# Sharp
COPY --from=build /temp/build /app/build
COPY entrypoint.sh /app
2023-11-19 16:05:07 -10:00
2023-11-26 19:30:57 -10: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-19 16:05:07 -10:00
2023-11-27 12:08:18 -10:00
# CD to app
WORKDIR /app
2023-11-27 15:47:39 -10:00
ENV NODE_ENV=production
2024-04-07 00:35:27 -10:00
ENTRYPOINT [ "/bin/bash", "/app/entrypoint.sh" ]
2023-11-27 15:47:39 -10:00
# Run migrations and start the server
2024-04-06 22:56:15 -10:00
CMD [ "start" ]