2024-07-11 13:34:24 +02:00
|
|
|
# Node is required for building the project
|
2024-07-28 00:38:42 +02:00
|
|
|
FROM imbios/bun-node:1-20-alpine AS base
|
2023-11-20 03:05:07 +01:00
|
|
|
|
2024-10-04 15:31:46 +02:00
|
|
|
RUN apk add --no-cache libstdc++
|
2024-04-14 14:18:17 +02: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
|
|
|
|
|
|
2023-12-09 02:00:02 +01:00
|
|
|
RUN mkdir -p /temp
|
2024-04-09 13:22:11 +02:00
|
|
|
COPY . /temp
|
2023-12-09 02:00:02 +01:00
|
|
|
WORKDIR /temp
|
2024-05-29 02:43:15 +02:00
|
|
|
RUN bun install --production
|
2023-11-20 03:05:07 +01:00
|
|
|
|
2024-06-29 08:49:17 +02:00
|
|
|
FROM base AS build
|
2024-04-07 08:13:09 +02:00
|
|
|
|
|
|
|
|
# Copy the project
|
|
|
|
|
RUN mkdir -p /temp
|
|
|
|
|
COPY . /temp
|
|
|
|
|
# Copy dependencies
|
|
|
|
|
COPY --from=install /temp/node_modules /temp/node_modules
|
2024-07-26 00:02:48 +02:00
|
|
|
|
2023-12-09 00:00:47 +01:00
|
|
|
# Build the project
|
2024-04-07 08:13:09 +02:00
|
|
|
WORKDIR /temp
|
2024-05-08 01:42:38 +02:00
|
|
|
RUN bun run build
|
2024-04-07 15:14:51 +02:00
|
|
|
WORKDIR /temp/dist
|
2023-12-09 00:00:47 +01:00
|
|
|
|
2024-04-14 06:15:15 +02:00
|
|
|
# Copy production dependencies and source code into final image
|
2025-01-23 15:28:16 +01:00
|
|
|
FROM oven/bun:1.2.0-alpine
|
2023-11-20 03:05:07 +01:00
|
|
|
|
2024-10-03 13:43:19 +02:00
|
|
|
# Install libstdc++ for Bun and create app directory
|
2024-10-04 15:31:46 +02:00
|
|
|
RUN apk add --no-cache libstdc++ && \
|
2024-10-03 13:43:19 +02:00
|
|
|
mkdir -p /app
|
2024-04-14 14:19:04 +02:00
|
|
|
|
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
|
|
|
|
2024-06-29 08:49:17 +02:00
|
|
|
LABEL org.opencontainers.image.authors="Gaspard Wierzbinski (https://cpluspatch.dev)"
|
2024-08-27 21:40:42 +02:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/versia-pub/server"
|
2024-08-19 15:16:01 +02:00
|
|
|
LABEL org.opencontainers.image.vendor="Versia Pub"
|
2024-06-29 08:49:17 +02:00
|
|
|
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
|
2024-08-19 15:16:01 +02:00
|
|
|
LABEL org.opencontainers.image.title="Versia Server"
|
|
|
|
|
LABEL org.opencontainers.image.description="Versia Server Docker image"
|
2023-11-20 03:05:07 +01:00
|
|
|
|
2024-07-26 00:17:54 +02:00
|
|
|
# Set current Git commit hash as an environment variable
|
|
|
|
|
ARG GIT_COMMIT
|
|
|
|
|
ENV GIT_COMMIT=$GIT_COMMIT
|
|
|
|
|
|
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-14 06:14:09 +02:00
|
|
|
ENTRYPOINT [ "/bin/sh", "/app/entrypoint.sh" ]
|
2023-11-28 02:47:39 +01:00
|
|
|
# Run migrations and start the server
|
2024-05-13 23:54:51 +02:00
|
|
|
CMD [ "cli", "start" ]
|