Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managing Dofigen in the build section #10615

Closed
taorepoara opened this issue May 24, 2023 · 3 comments
Closed

Managing Dofigen in the build section #10615

taorepoara opened this issue May 24, 2023 · 3 comments

Comments

@taorepoara
Copy link

Description

Dofigen help creating Dockerfiles by defining the structure using YAML.

Managing Dofigen to make it usable instead of the Dockerfile field to define the Dofigen file:

services:
  webapp:
    build:
      context: .
      dofigen: dofigen.yml

Or directly define it like in the next example the builds a TypeScript project:

services:
  webapp:
    build:
      context: .
      dofigen: 
        builders:
          - name: module-loader
            from: &image "docker.io/bitnami/node:18"
            workdir: /tmp/module
            adds:
              - package.json
              - package-lock.json
            script:
              - npm ci --omit=dev --cache /tmp/cache
            caches:
              - /tmp/cache
          - name: builder
            from: *image
            workdir: /tmp/app
            adds:
              - .
            script:
              - npm i --cache /tmp/cache
              - npm run build
            caches:
              - /tmp/cache
        from: *image
        workdir: /app
        artifacts:
          - builder: module-loader
            source: "/tmp/module/"
            destination: "/app/"
          - builder: builder
            source: "/tmp/app/dist/"
            destination: "/app/dist/"
          - builder: builder
            source: "/tmp/app/resources/"
            destination: "/app/resources/"
        cmd:
          - node
          - node_modules/@lenra/app-server/dist/bin/app-lenra.js
        ports:
          - 3000
        envs:
          NODE_ENV: production
        ignores:
          - "**"
          - "!/*.json"
          - "!/src/"
          - "!/resources/"
@ndeloof
Copy link
Contributor

ndeloof commented May 24, 2023

Changes in the compose file format should be discussed on github.com/compose-spec/compose-spec.
Anyway, I don't expect we approve introducing into the compose-spec schema support for a nested format. Anyway it makes sense imho we don't get stuck with docker build approach for building images from a Dockerfile.

I suggest we investigate the ability to declare a configurable image builder:

services:
  webapp:
      build:
          context: .
          image-builder: # defaults to `docker`

with this set, docker compose build could then delegate image build to third party tool. For your example this would result into:

services:
  webapp:
      build:
          context: .
          image-builder: dofigen
          x-dofigen-file: dofigen.yml  # custom extension can be used to pass parameters to plugable image builder

This could also be used to force use of buildkit, even when disabled by configuration, as Dockerfile might require advanced features and would fail with the classic builder.

Same would allow to integrate dotnet publish or any comparable solution

@ndeloof ndeloof changed the title Managing Dofigen is the build section Managing Dofigen in the build section May 24, 2023
@taorepoara
Copy link
Author

taorepoara commented May 25, 2023

Actually, Dofigen is not a builder, it only generate the Dockerfile and .dockerignore, but I uderstand the point. I'll think to make it generic and I'll propose it on compose-spec.

@ndeloof
Copy link
Contributor

ndeloof commented May 30, 2023

I'm closing this issue as such discussion should take place under compose specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants