refactor: update Dockerfile for improved workspace structure and buil… #47

Merged
killer-cf merged 1 commits from config-self-convex into master 2025-11-26 13:48:52 +00:00
2 changed files with 20 additions and 8 deletions
Showing only changes of commit 75989b0546 - Show all commits

View File

@@ -25,7 +25,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ./apps/web
context: .
file: ./Dockerfile
push: true
# Make sure to replace with your own namespace and repository

View File

@@ -8,19 +8,30 @@ WORKDIR /usr/src/app
RUN addgroup --system --gid 1001 sveltekit
RUN adduser --system --uid 1001 sveltekit
# Copy package.json and bun.lockb (if available)
COPY package.json bun.lockb* ./
# Copy package.json and bun.lock (if available)
COPY package.json bun.lock* ./
# Copy workspace packages first (needed for bun install to resolve local dependencies)
# Copy package.json files to establish workspace structure
COPY packages/backend/package.json ./packages/backend/
COPY packages/eslint-config/package.json ./packages/eslint-config/
# Copy eslint-config files (needed for the package to be valid)
COPY packages/eslint-config/*.js ./packages/eslint-config/
# Copy apps/web package.json (also part of the workspace)
COPY apps/web/package.json ./apps/web/
# Install dependencies (including dev dependencies for build)
# This will resolve workspace dependencies using the package.json files we just copied
RUN bun install --frozen-lockfile
# Copy the source code
# Copy the rest of the source code
COPY . .
# Prepare SvelteKit and build the application
# Navigate to web app directory and build
WORKDIR /usr/src/app/apps/web
RUN bun run prepare
RUN bun run build
RUN bun run db:migrate
# Production stage
FROM oven/bun:1-slim AS production
@@ -33,12 +44,13 @@ RUN addgroup --system --gid 1001 sveltekit
RUN adduser --system --uid 1001 sveltekit
# Copy built application from base stage
COPY --from=base --chown=sveltekit:sveltekit /usr/src/app/build ./build
COPY --from=base --chown=sveltekit:sveltekit /usr/src/app/package.json ./package.json
COPY --from=base --chown=sveltekit:sveltekit /usr/src/app/apps/web/build ./build
COPY --from=base --chown=sveltekit:sveltekit /usr/src/app/apps/web/package.json ./package.json
# Copy node_modules from root (Bun manages workspaces centrally)
COPY --from=base --chown=sveltekit:sveltekit /usr/src/app/node_modules ./node_modules
# Copy any additional files needed for runtime
COPY --from=base --chown=sveltekit:sveltekit /usr/src/app/static ./static
COPY --from=base --chown=sveltekit:sveltekit /usr/src/app/apps/web/static ./static
# Switch to non-root user
USER sveltekit