cuber-gem icon indicating copy to clipboard operation
cuber-gem copied to clipboard

Allows to provide build-args to the Dockerfile build process

Open webmatze opened this issue 2 years ago • 2 comments

I needed the ability to add build-args to the build process of the Dockerfile.

So I added it to the Cuberfile parser.

Example:

app 'test'
repo '.'
dockerfile 'Dockerfile'
dockerconfig 'config/dockerconfig.json'
image 'my/image-name'
buildarg 'RAILS_ENV', 'stage'
buildarg 'VERSION', 'v1.2.3'
proc :web, 'bundle exec rails s'

Maybe you'll find the useful or have any requests for changes.

Thank you anyhow for this amazing gem. 😄

webmatze avatar Aug 26 '22 21:08 webmatze

I was thinking about your example above and I wonder if you can use separate Cuberfiles and Dockerfiles for each environment.

For example in a folder cuber/staging/Cuberfile you will have the definition for the staging environment:

app 'test'
repo '.'
dockerfile 'Dockerfile.staging'
dockerconfig 'config/dockerconfig.json'
image 'my/image-name'
proc :web, 'bundle exec rails s'

Note that I use dockerfile 'Dockerfile.staging' and I have removed the build args.

I suggest this because in different environments you will probably have many differences (different env variables, different scaling of resources, etc.). So using the same Cuberfile for multiple environments would be difficult (too many conditions and subtle differences).

Let me know

collimarco avatar Sep 01 '22 11:09 collimarco

Sorry for replying so late. Separate Cuber- and Dockerfiles is defenitely a way to go.

webmatze avatar Sep 14 '22 09:09 webmatze