80 lines
1.5 KiB
Django/Jinja
80 lines
1.5 KiB
Django/Jinja
{% if frontend_adapter == 'bun' -%}
|
|
FROM oven/bun:alpine AS deps
|
|
|
|
ENV TERM=xterm-256color
|
|
ENV COLORTERM=truecolor
|
|
ENV BUN_INSTALL_CACHE_DIR=/bun-cache
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json bun.lock* ./
|
|
|
|
RUN --mount=type=cache,target=/bun-cache bun install --frozen-lockfile
|
|
|
|
|
|
# .env is in the context ($env/static/* are inlined at build) and stays in
|
|
# this stage: the runtime image below gets build/ and production deps only.
|
|
FROM deps AS builder
|
|
|
|
COPY . .
|
|
|
|
RUN bun --bun svelte-kit sync
|
|
RUN bun --bun run build
|
|
|
|
|
|
FROM oven/bun:alpine AS runtime
|
|
|
|
ENV NODE_ENV=production
|
|
# The cache mount only holds files; without the variable bun caches into
|
|
# ~/.bun inside the image.
|
|
ENV BUN_INSTALL_CACHE_DIR=/bun-cache
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json bun.lock* ./
|
|
|
|
RUN --mount=type=cache,target=/bun-cache bun install --frozen-lockfile --production
|
|
|
|
COPY --from=builder /app/build ./build
|
|
|
|
EXPOSE 3000
|
|
|
|
ENTRYPOINT ["bun"]
|
|
CMD ["build/index.js"]
|
|
{%- else -%}
|
|
FROM oven/bun:alpine AS deps
|
|
|
|
ENV TERM=xterm-256color
|
|
ENV COLORTERM=truecolor
|
|
ENV BUN_INSTALL_CACHE_DIR=/bun-cache
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json bun.lock* ./
|
|
|
|
RUN --mount=type=cache,target=/bun-cache bun install --frozen-lockfile
|
|
|
|
|
|
FROM deps AS builder
|
|
|
|
COPY . .
|
|
|
|
RUN bun --bun svelte-kit sync
|
|
RUN bun run build
|
|
|
|
|
|
FROM oven/bun:alpine AS runtime
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/build ./build
|
|
COPY --from=builder /app/serve.ts ./serve.ts
|
|
|
|
EXPOSE 3000
|
|
|
|
ENTRYPOINT ["bun"]
|
|
CMD ["run", "serve.ts"]
|
|
{%- endif %}
|