Hacker News new | ask | show | jobs
by nikeee 888 days ago
I'm wondering why it's not more common to indent the stages in a multi-stage build. For me, it's a no-brainer to see at a glance

1. how many stages there are

2. how long they are

3. the dependencies

Taking the example from the article:

  FROM node:18-alpine as builder
      WORKDIR /app
      COPY ./package* .
      RUN npm ci
      COPY . .
      RUN npm run build:client

  FROM nginxinc/nginx-unprivileged:1.24 as serve
      COPY --from=builder /app/dist /var/www
      COPY --from=builder /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
      EXPOSE 80
      CMD ["nginx", "-g", "daemon off;"]
IMHO it's just so more legible. Without this, it feels like writing C without indentation. Unfortunately the Jetbrains IDEs fail to properly apply syntax highlighting.
1 comments

I've never really had the chance to try it, but buildah seems like a decent enough choice to build images using basic shell tooling. At least then you don't need to muck around with build-args or other limitations of the dockerfile DSL.