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

ci: support for stable build #29

Merged
merged 1 commit into from
Sep 8, 2021
Merged

ci: support for stable build #29

merged 1 commit into from
Sep 8, 2021

Conversation

jenhagg
Copy link
Collaborator

@jenhagg jenhagg commented Aug 30, 2021

Purpose

Add version argument to docker build which allows reusing the dockerfile to produce both latest and stable images.

What the code is doing

The latest branch is unchanged, but now we could also pass stable as an input to the workflow, which will get passed as a build-arg to docker, causing it to install the package from PyPI instead. The default image in the compose file is changed to be stable, but a user can override this using the .dev.yml file.

Testing

Tested the bash script and stable build from the command line, and tested the workflow input functionality in my test-ci repo. Example:

cd build
docker build . -t client:stable --build-arg version=stable

Time estimate

5 min

@jenhagg jenhagg marked this pull request as ready for review September 2, 2021 22:43
@jenhagg jenhagg self-assigned this Sep 2, 2021
@@ -1,4 +1,5 @@
FROM python:3.8.3
ARG version=latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a detail but why is the default in the Dockerfile latest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's arbitrary, but nice to have a default so if we do a docker build with no --build-arg we still get something useful. Note, we also duplicate that default value in the workflow inputs, since the workflow-trigger action doesn't yet support that.

@kasparm kasparm self-requested a review September 8, 2021 16:01
Copy link
Contributor

@kasparm kasparm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good.

Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just to confirm my read, from now on, if we build an image, a build-arg being either stable or latest should be specified, right? There is no default behavior without specifying the parameter. But if we run docker compose, for docker-compose.dev.yml, it will do latest and for docker-compose.yml, it's stable.

@jenhagg
Copy link
Collaborator Author

jenhagg commented Sep 8, 2021

Just to confirm my read, from now on, if we build an image, a build-arg being either stable or latest should be specified, right? There is no default behavior without specifying the parameter.

The version build arg is only required for stable since it's defaulted to latest in the Dockerfile. But it is correct to say that it must be one of those two values.

But if we run docker compose, for docker-compose.dev.yml, it will do latest and for docker-compose.yml, it's stable.

Kind of, but just to clarify, pretty much all you can do with docker-compose.dev.yml on its own is the latest build. E.g. you can run docker-compose -f docker-compose.dev.yml build and that will work fine. But something like docker-compose -f docker-compose.dev.yml up won't really work as expected unless the base docker-compose.yml file is also included, as in this section of the readme. To be honest if I want to use latest, I would probably just build it and edit docker-compose.yml to use that instead, but the .dev.yml file provides a way to do that without changing anything.

@jenhagg jenhagg merged commit fd57f2b into main Sep 8, 2021
@jenhagg jenhagg deleted the jon/build branch September 8, 2021 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants