Hi,
I'm trying to port this dockerfile to nodejs/ts dagger code.
how should I set up the base container so that builder, installer containers etc can be created based on it?
ie if I created the base like this
const base = client
.container({ platform: 'linux/amd64' as Platform })
.from('node:18');
is creating additional containers like this is enough?
const builder = base.withExec(,,,)
...
Or is should it be something like
const installer = client.container().from(base) // I know that from() doesn't take such parameter but just to illustrate the assumption.
...
here's the dockerfile I'm porting;
FROM node:18-alpine AS base
FROM --platform=linux/amd64 base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN npm install -g turbo
COPY . .
RUN turbo prune --scope=web --docker
# Add lockfile and package.json's of isolated subworkspace
FROM --platform=linux/amd64 base AS installer
RUN apk add --no-cache libc6-compat python3 make g++
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json
RUN npm ci install
# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
ENV NEXT_TELEMETRY_DISABLED 1
RUN npm run build --filter=web...
FROM --platform=linux/amd64 base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json .
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
CMD node apps/web/server.js