You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
# Dockerfile for production deployments of Alexandria. |
|
# Based on the Bun Docker guide: https://bun.sh/guides/ecosystem/docker. |
|
|
|
# Use the official Bun image |
|
FROM oven/bun:1.2-alpine AS base |
|
WORKDIR /usr/src/app |
|
|
|
# TODO: This expects the lockfile to already exist. |
|
# It doesn't, so build it, and ensure it gets cached. |
|
|
|
# Install dependencies into a temp directory. |
|
# This will cache them and speed up future builds. |
|
FROM base AS install |
|
RUN mkdir -p /temp/dev |
|
COPY package.json /temp/dev/ |
|
RUN cd /temp/dev && bun install |
|
|
|
# Copy node_modules from temp directory. |
|
# Then copy all (non-ignored) project files into the image. |
|
FROM base AS prerelease |
|
ENV NODE_ENV=development |
|
ENV ALEX_HOST=0.0.0.0 |
|
ENV ALEX_PORT=3040 |
|
ENV ALEX_ORIGIN=https://next-alexandria.gitcitadel.eu |
|
COPY --from=install /temp/dev/node_modules node_modules |
|
COPY . . |
|
|
|
# Run tests and build. |
|
# RUN bun test # Uncomment when tests are ready. |
|
RUN bun run build |
|
|
|
# Copy production dependencies and source code into final image. |
|
FROM base AS release |
|
ENV NODE_ENV=development |
|
ENV ALEX_HOST=0.0.0.0 |
|
ENV ALEX_PORT=3040 |
|
ENV ALEX_ORIGIN=https://next-alexandria.gitcitadel.eu |
|
COPY --from=prerelease /usr/src/app/build . |
|
|
|
# Run the app. |
|
USER bun |
|
EXPOSE 3040/tcp |
|
ENTRYPOINT [ "bun", "run", "start" ]
|
|
|