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

Extend version with more build info #3682

Open
micves opened this issue Feb 18, 2024 · 5 comments
Open

Extend version with more build info #3682

micves opened this issue Feb 18, 2024 · 5 comments
Labels
docker Pull requests that update Docker code enhancement New feature or request

Comments

@micves
Copy link
Contributor

micves commented Feb 18, 2024

It could be useful to have some more info than just the version number when testing out PR's

It could be just a log output when starting teslamate, but might also be handy on settings on web.

I guess we would need something like this to be able to backtrace it completely:

  • PR #
  • PR origin: fork and revision
  • build date and time

Originally posted by @micves in #3658 (reply in thread)

@brianmay
Copy link
Collaborator

In my Elixir projects I have:

Dockerfile:

# Setup access to version information
ARG BUILD_DATE=date
ARG VCS_REF=vcs
ENV BUILD_DATE=${BUILD_DATE}
ENV VCS_REF=${VCS_REF}

In the build, I use a custom action to pass the appropriate values for these args. I did these with a github action, but maybe we won't have to do that here(???): https://github.com/brianmay/docker-meta/blob/main/index.js

I notice I have an extra variable here for VERSION to which I don't consume. Curious. I may have forgotten to update the project. And there is a bit of logic here to pass the branch name, tag, or whatever to generate the version. I actually can't remember why I did it this way anymore.

You should be able to use these predefined variables: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables

Then I read these values in the elixir config:

config :xxx,
  build_date: System.get_env("BUILD_DATE"),
  vcs_ref: System.get_env("VCS_REF"),
  [...]

@JakobLichterfeld
Copy link
Collaborator

We build our ghcr images with just pr-xxxx right now, innit?
So agree a commit id would be great

@JakobLichterfeld JakobLichterfeld added enhancement New feature or request docker Pull requests that update Docker code labels Feb 20, 2024
@JakobLichterfeld
Copy link
Collaborator

If you want to change the version in a PR, just update the version file...

@micves
Copy link
Contributor Author

micves commented Feb 20, 2024

We build our ghcr images with just pr-xxxx right now, innit?
So agree a commit id would be great

I think the image name is fine 👍 This way you can just pull without changing anything and get a new image from the PR.
The idea was to get some output indicating that it was actually updated (log and/or web)

If you want to change the version in a PR, just update the version file...

I always forget to update things like that :D

Maybe something like this could be nice where the version is detected automatically from the latest tag:
https://elixirforum.com/t/generating-app-mix-version-directly-from-git-tags/16685/7

And bumbed if not on tag. That means it would work for the edge image as well.

If no one beats me to it, I might try it out in a PR at some point :)

@JakobLichterfeld
Copy link
Collaborator

Yeah, I used the version bumping in the past as well, but this will not update the log output in elixir from what I get, therefore TeslaMate uses the version file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Pull requests that update Docker code enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants