Skip to content

Commit

Permalink
Fix Docker image to specific Golang version
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ruflin committed Sep 17, 2019
1 parent a575c39 commit 3078aa0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.13.0
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:latest
ARG GO_VERSION
FROM golang:${GO_VERSION:-1.13.0}

RUN \
apt-get update \
Expand All @@ -20,5 +21,6 @@ RUN mage build
# If we keep it, it means all packages exist twice.
RUN rm -rf dev

ENTRYPOINT ["go", "run", "."]
# Make sure it's accessible from outside the container
ENTRYPOINT ["go", "run", ".", "--address=0.0.0.0:8080"]
CMD ["--address=0.0.0.0:8080"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ There are several options to run this.

### Go command

To use the correct golang version, run:

```
gvm use $(cat .go-version)
```

When using the go command, first the example packages must be built:

`mage build`
Expand Down

0 comments on commit 3078aa0

Please sign in to comment.