Multi-Stage Dockerfiles
-
Dear @staff ,
I would like to request to accept Multi Stage Dockerfiles for Cloudron packages.
As at the end only the generated Docker Image is what is relevent, it should be accepted if a Multi Stage Dockerfile has been used to build the Cloudron Package Docker Image.
IMHO this would speed up package creation a lot.
Best,
Mike -
@Kubernetes should be OK. We tried this out the typebot package and it's been working out OK so far.
As always, the main thing is that all the images must be pinned to a tag. The primary image should be the Cloudron base image.
-
@girish okay, so that means, this example of a Dockerfile would be acceptable?
FROM node:20-alpine as build-stage WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN npm run build FROM cloudron/base:4.2.0@sha256:46da2fffb36353ef714f97ae8e962bd2c212ca091108d768ba473078319a47f4 as production-stage WORKDIR /app COPY --from=build-stage /app/node_modules ./node_modules COPY --from=build-stage /app/package.json ./ COPY --from=build-stage /app/dist ./dist COPY --from=build-stage /app/server.js ./ COPY --from=build-stage /app/static-server.js ./ COPY --from=build-stage /app/api ./api EXPOSE 18966 CMD ["npm", "start"]
-
@Kubernetes good suggestion
If I see something interesting to package, but then see it's a multi-stage build, I run a mile on the basis that it will too complex to convert into a single-build model. -
@Kubernetes yes, looks good!
-
I’m using multi stage dockerfiles for my projects, works like a charm. Only for final stage I use the cloudron base image.
-
@Kubernetes That's what I've done for the GROWI package so far, and apart from the things left to do, it works really well and makes things easier
-
From Arya:
"Multi-stage Docker files are a way to build Docker images in multiple stages, allowing you to create a more efficient and optimized final image. This is useful because it allows you to separate the build environment from the final runtime environment, removing unnecessary dependencies and reducing image size. This leads to faster build times, less vulnerability to security issues, and easier deployment of the final image."
-
@Lanhild yup, we already started using multi-stage builds by now. For app store, you have to pin the images though. Using ":latest" is not good will have to be changed.