feat(backend): support partial/conditional builds in Dockerfile
This commit is contained in:
@@ -1,32 +1,41 @@
|
|||||||
FROM oven/bun:1.2.18 AS website-builder
|
FROM oven/bun:1.2.18 AS builder
|
||||||
WORKDIR /website
|
WORKDIR /build
|
||||||
COPY website/package.json ./
|
|
||||||
RUN bun install
|
|
||||||
COPY website/ .
|
|
||||||
RUN bun run build
|
|
||||||
|
|
||||||
FROM oven/bun:1.2.18 AS mobile-builder
|
# Copy the entire build context (which contains whatever project folders exist)
|
||||||
WORKDIR /mobile
|
COPY . .
|
||||||
COPY mobile/package.json ./
|
|
||||||
RUN bun install
|
|
||||||
COPY mobile/ .
|
|
||||||
RUN bun run build:web
|
|
||||||
|
|
||||||
FROM oven/bun:1.2.18 AS games-builder
|
# Conditionally build website if present
|
||||||
WORKDIR /games
|
RUN if [ -d "website" ]; then \
|
||||||
COPY games/package.json ./
|
cd website && bun install && bun run build && cd ..; \
|
||||||
RUN bun install
|
fi
|
||||||
COPY games/ .
|
|
||||||
RUN bun run build
|
# Conditionally build mobile if present
|
||||||
|
RUN if [ -d "mobile" ]; then \
|
||||||
|
cd mobile && bun install && bun run build:web && cd ..; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Conditionally build games if present
|
||||||
|
RUN if [ -d "games" ]; then \
|
||||||
|
cd games && bun install && bun run build && cd ..; \
|
||||||
|
fi
|
||||||
|
|
||||||
FROM oven/bun:1.2.18
|
FROM oven/bun:1.2.18
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy backend configuration and install production dependencies
|
||||||
COPY backend/package.json backend/bun.lock backend/tsconfig.json ./
|
COPY backend/package.json backend/bun.lock backend/tsconfig.json ./
|
||||||
RUN bun install --frozen-lockfile --production
|
RUN bun install --frozen-lockfile --production
|
||||||
|
|
||||||
|
# Copy backend source code
|
||||||
COPY backend/src ./src
|
COPY backend/src ./src
|
||||||
COPY --from=website-builder /website/dist ./public
|
|
||||||
COPY --from=mobile-builder /mobile/dist ./public/mobile
|
# Create public assets directories
|
||||||
COPY --from=games-builder /games/dist ./public/games
|
RUN mkdir -p public public/mobile public/games
|
||||||
|
|
||||||
|
# Conditionally copy build assets from the builder stage if they exist
|
||||||
|
RUN if [ -d "/build/website/dist" ]; then cp -r /build/website/dist/* ./public/; fi
|
||||||
|
RUN if [ -d "/build/mobile/dist" ]; then cp -r /build/mobile/dist/* ./public/mobile/; fi
|
||||||
|
RUN if [ -d "/build/games/dist" ]; then cp -r /build/games/dist/* ./public/games/; fi
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=8080
|
ENV PORT=8080
|
||||||
|
|||||||
Reference in New Issue
Block a user