faster docker builds
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.svelte-kit
|
||||||
|
.git
|
||||||
|
build
|
||||||
25
Dockerfile
25
Dockerfile
@@ -1,28 +1,23 @@
|
|||||||
FROM oven/bun AS base
|
FROM oven/bun AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies (cached unless package.json/bun.lock change)
|
||||||
FROM base AS install
|
FROM base AS deps
|
||||||
RUN mkdir -p /temp/dev
|
COPY package.json bun.lock ./
|
||||||
COPY package.json bun.lock /temp/dev/
|
RUN bun install --frozen-lockfile
|
||||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
||||||
|
|
||||||
RUN mkdir -p /temp/prod
|
# Build (mount cache so SvelteKit reuses previous build artifacts)
|
||||||
COPY package.json bun.lock /temp/prod/
|
|
||||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
|
||||||
|
|
||||||
# Build
|
|
||||||
FROM base AS build
|
FROM base AS build
|
||||||
COPY --from=install /temp/dev/node_modules node_modules
|
COPY --from=deps /app/node_modules node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
RUN bun run build
|
RUN --mount=type=cache,target=/app/.svelte-kit bun run build
|
||||||
|
|
||||||
# Runtime
|
# Runtime — prod deps only
|
||||||
FROM base AS runtime
|
FROM base AS runtime
|
||||||
COPY --from=install /temp/prod/node_modules node_modules
|
COPY package.json bun.lock ./
|
||||||
|
RUN bun install --frozen-lockfile --production
|
||||||
COPY --from=build /app/build build
|
COPY --from=build /app/build build
|
||||||
COPY --from=build /app/package.json .
|
|
||||||
|
|
||||||
USER bun
|
USER bun
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|||||||
Reference in New Issue
Block a user