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

Fix Docker image to specific Golang version #107

Merged
merged 1 commit into from
Sep 17, 2019

Conversation

ruflin
Copy link
Contributor

@ruflin ruflin commented Sep 12, 2019

So far the :latest image was used for Golang. To be used in production I prefer to tied it to a very specific version so we know what is run and what we test is identical.

A file .go-version was introduced which long term should serve as the single point of through for the go version, also for CI. At the moment it is only there for documentation purpose.

The ENTRYPOINT of the Dockerfile was split up into ENTRYPOINT to make it easier to overwrite parameters.

Note: As part of this change I also looked into using the alpine Golang image but it does not have Git included, which makes working with the Golang mod dependency trickier.

.go_version Outdated
@@ -0,0 +1 @@
1.13.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrewkroh It would be nice if gvm would support something like gvm use and has a convention which file it uses. Perhaps there is already something like this but I missed it?

Copy link
Member

Choose a reason for hiding this comment

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

You can run a command like gvm use $(cat .go-version) but there's nothing built-in for reading a file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WDYT about creating a "default" location for a file similar to what nvm use does. to get rid of the cat magic?

Copy link
Member

@andrewkroh andrewkroh Sep 16, 2019

Choose a reason for hiding this comment

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

I don't have an issue with such a feature as described for .nvmrc. But I also don't see a whole lot of extra value in it either since it's easy to read the file explicitly with a shell. It might help establish a convention for specifying the Go version in a project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would expect it helps for cross stack compatibility. Will go for now with the shell version. Worth opening an issue in gvm?

Copy link
Member

Choose a reason for hiding this comment

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

Definitely open an issue for it. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -1,4 +1,4 @@
FROM golang:latest
FROM golang:${GO_VERSION:-1.13.0}
Copy link
Member

Choose a reason for hiding this comment

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

If you want to force the version to come from an outside arg you could do

ARG GO_VERSION
FROM golang:${GO_VERSION}

and run docker build --build-arg GO_VERSION=$(cat .go_version) .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ups, missed the ARG line. That was exactly what I wanted to do.

So far the `:latest` image was used for Golang. To be used in production I prefer to tied it to a very specific version so we know what is run and what we test is identical.

A file `.go-version` was introduced which long term should serve as the single point of through for the go version, also for CI. At the moment it is only there for documentation purpose.

The ENTRYPOINT of the Dockerfile was split up into ENTRYPOINT to make it easier to overwrite parameters.

Note: As part of this change I also looked into using the alpine Golang image but it does not have Git included, which makes working with the Golang mod dependency trickier.
@ruflin ruflin merged commit 3acbd6e into elastic:master Sep 17, 2019
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.

2 participants