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
|
2024-04-06 20:13:09 -10:00
|
|
|
|
2024-10-04 15:31:46 +02:00
|
|
|
RUN apk add --no-cache libstdc++
|
2024-04-14 02:18:17 -10:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
RUN mkdir -p /temp
|
2024-04-09 01:22:11 -10:00
|
|
|
COPY . /temp
|
2024-04-06 20:13:09 -10:00
|
|
|
WORKDIR /temp
|
2024-05-28 14:43:15 -10:00
|
|
|
RUN bun install --production
|
2024-04-06 20:13:09 -10:00
|
|
|
|
2024-06-28 20:49:17 -10:00
|
|
|
FROM base AS build
|
2023-11-19 16:05:07 -10:00
|
|
|
|
2024-04-06 20:13:09 -10:00
|
|
|
# Copy the project
|
2023-12-08 15:00:02 -10:00
|
|
|
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
|
2024-07-26 00:02:48 +02:00
|
|
|
|
2023-12-08 13:00:47 -10:00
|
|
|
# Build the project
|
2024-04-06 20:13:09 -10:00
|
|
|
WORKDIR /temp
|
2024-05-07 23:42:38 +00:00
|
|
|
RUN bun run build
|
2024-04-07 03:14:51 -10:00
|
|
|
WORKDIR /temp/dist
|
2023-12-08 13:00:47 -10:00
|
|
|
|
2024-04-13 18:15:15 -10:00
|
|
|
# Copy production dependencies and source code into final image
|
2024-11-28 10:27:17 +01:00
|
|
|
FROM oven/bun:1.1.37-alpine
|
2023-11-19 16:05:07 -10: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 02:19:04 -10:00
|
|
|
|
2024-04-06 20:13:09 -10:00
|
|
|
COPY --from=build /temp/dist /app/dist
|
2023-12-08 13:00:47 -10:00
|
|
|
COPY entrypoint.sh /app
|
2023-11-19 16:05:07 -10:00
|
|
|
|
2024-06-28 20:49:17 -10: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-28 20:49:17 -10: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-19 16:05:07 -10: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 12:08:18 -10:00
|
|
|
# CD to app
|
|
|
|
|
WORKDIR /app
|
2023-11-27 15:47:39 -10:00
|
|
|
ENV NODE_ENV=production
|
2024-04-13 18:14:09 -10:00
|
|
|
ENTRYPOINT [ "/bin/sh", "/app/entrypoint.sh" ]
|
2023-11-27 15:47:39 -10:00
|
|
|
# Run migrations and start the server
|
2024-05-13 11:54:51 -10:00
|
|
|
CMD [ "cli", "start" ]
|