From 38375961b0c06bd5b395f3dd51adf47f201d6599 Mon Sep 17 00:00:00 2001 From: Mike Conrad Date: Sun, 8 Jun 2025 11:50:05 -0400 Subject: [PATCH] Update multistage example --- slides.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/slides.md b/slides.md index 540ece8..edf6c73 100644 --- a/slides.md +++ b/slides.md @@ -236,28 +236,32 @@ layout: center ## Multi Stage builds ```dockerfile -# Stage 1: Build the Go binary +# Stage 1 - Define Base image FROM node:22-alpine AS base -FROM base AS build -# Set working directory inside the build container +# Stage 2 Install dependencies +FROM base AS install-deps WORKDIR /app -COPY package*.json ./ +COPY package*.json /app/ RUN yarn - -FROM base AS develop -COPY --from=base /app/node_modules /app/node_modules +# Stage 3 Development +FROM install-deps AS develop +WORKDIR /app +COPY --from=install-deps /app/node_modules /app/node_modules COPY . . - -ENTRYPOINT ["yarn", "dev"] -EXPOSE 3000 +ENTRYPOINT ["yarn", "dev", "--host=0.0.0.0"] +EXPOSE 5173 ``` -- Use specific versions, not `latest` -- Combine commands to reduce layers -- Use `.dockerignore` -- Prefer slim or alpine images -- Run as non-root user if possible - +```bash +$ docker build -t react . +$ docker run --rm -P react +``` + --- transition: fade-out layout: center