2024-11-25 21:54:31 +01:00
|
|
|
# Node is required for building the project
|
2025-07-06 02:10:44 +02:00
|
|
|
FROM imbios/bun-node:latest-23-alpine AS base
|
2024-11-25 21:54:31 +01:00
|
|
|
|
|
|
|
|
# Install dependencies into temp directory
|
|
|
|
|
# This will cache them and speed up future builds
|
|
|
|
|
FROM base AS install
|
|
|
|
|
|
|
|
|
|
RUN mkdir -p /temp
|
|
|
|
|
COPY . /temp
|
|
|
|
|
WORKDIR /temp
|
|
|
|
|
RUN bun install --production
|
|
|
|
|
|
|
|
|
|
FROM base AS build
|
|
|
|
|
|
|
|
|
|
# Copy the project
|
|
|
|
|
RUN mkdir -p /temp
|
|
|
|
|
COPY . /temp
|
|
|
|
|
# Copy dependencies
|
|
|
|
|
COPY --from=install /temp/node_modules /temp/node_modules
|
|
|
|
|
|
|
|
|
|
# Build the project
|
|
|
|
|
WORKDIR /temp
|
2025-07-06 02:10:44 +02:00
|
|
|
RUN bun run build worker
|
2024-11-25 21:54:31 +01:00
|
|
|
WORKDIR /temp/dist
|
|
|
|
|
|
|
|
|
|
# Copy production dependencies and source code into final image
|
2025-07-06 02:03:27 +02:00
|
|
|
FROM oven/bun:1.2.18-alpine
|
2024-11-25 21:54:31 +01:00
|
|
|
|
|
|
|
|
# Install libstdc++ for Bun and create app directory
|
2025-07-06 02:10:44 +02:00
|
|
|
RUN mkdir -p /app
|
2024-11-25 21:54:31 +01:00
|
|
|
|
|
|
|
|
COPY --from=build /temp/dist /app/dist
|
|
|
|
|
COPY entrypoint.sh /app
|
|
|
|
|
|
2025-07-06 02:10:44 +02:00
|
|
|
LABEL org.opencontainers.image.authors="Gaspard Wierzbinski (https://cpluspatch.com)"
|
2024-11-25 21:54:31 +01:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/versia-pub/server"
|
|
|
|
|
LABEL org.opencontainers.image.vendor="Versia Pub"
|
|
|
|
|
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
|
|
|
|
|
LABEL org.opencontainers.image.title="Versia Server Worker"
|
|
|
|
|
LABEL org.opencontainers.image.description="Versia Server Worker Docker image"
|
|
|
|
|
|
|
|
|
|
# Set current Git commit hash as an environment variable
|
|
|
|
|
ARG GIT_COMMIT
|
|
|
|
|
ENV GIT_COMMIT=$GIT_COMMIT
|
|
|
|
|
|
|
|
|
|
# CD to app
|
2025-07-06 02:10:44 +02:00
|
|
|
WORKDIR /app
|
2024-11-25 21:54:31 +01:00
|
|
|
ENV NODE_ENV=production
|
2025-07-06 02:10:44 +02:00
|
|
|
ENTRYPOINT [ "/bin/sh", "/app/entrypoint.sh" ]
|
2024-11-25 21:54:31 +01:00
|
|
|
# Run migrations and start the server
|
2025-04-30 02:53:58 +02:00
|
|
|
CMD [ "bun", "run", "worker.js" ]
|