feat: update Dockerfile and .dockerignore for improved build process and dependency management

This commit is contained in:
yuanhau 2025-05-09 22:58:22 +08:00
parent 50846c91c2
commit 2e9845c268
2 changed files with 28 additions and 13 deletions

View file

@ -5,3 +5,8 @@ node_modules
dist
.git
.env
.DS_Store
npm-debug.log
yarn-debug.log
yarn-error.log
.env.*

View file

@ -1,28 +1,38 @@
# Building process
FROM oven/bun:latest as builder
WORKDIR /app
# Copy dependency files
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile
# Copy source files
# Copy package.json first
COPY package.json ./
# Copy lock files if they exist (support both bun and npm/yarn)
COPY bun.lockb* package-lock.json* yarn.lock* ./
# Install dependencies
RUN bun install --frozen-lockfile || bun install
# Copy remaining source files
COPY . .
# Framework-specific build command
# Build the application
RUN bun run build
# Production image
# Production stage
FROM oven/bun:latest
WORKDIR /app
# Copy built assets and dependencies
COPY --from=builder /app/.output /app/.output
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/build /app/build
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/bun.lockb /app/bun.lockb
COPY --from=builder /app/package.json ./
COPY --from=builder /app/bun.lockb* ./
# If you have customized your output directory, please add your custom one here, or just remove it. :)
# Install production dependencies only
RUN bun install --production --frozen-lockfile
# Install production dependencies
RUN bun install --production
EXPOSE 3000
# Map the prod command to start via editing your package.json like in the example.package.json
CMD ["bun", "run", "start"]