Skip to content

Commit

Permalink
Git commit reference mechanism changed
Browse files Browse the repository at this point in the history
- Git commit is passed as a build argument as explained in README.md
- `.git` directory is ignored by Docker for a quicker build and smaller context
- the build arg VCS_REF is used both to tag the image and the Go program
  • Loading branch information
qdm12 committed Jul 1, 2019
1 parent 330131b commit fd70aaa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Expand Up @@ -9,3 +9,4 @@ coverage.txt
Dockerfile
LICENSE
test.sh
.git
5 changes: 3 additions & 2 deletions Dockerfile
Expand Up @@ -7,16 +7,17 @@ FROM ${BASE_IMAGE_BUILDER}:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
ARG GOARCH=amd64
ARG GOARM
ARG VERSION=0.2.4
RUN apk --update add -q --progress git
ARG VCS_REF=
WORKDIR /go/src/github.com/jesseduffield/lazydocker/
COPY ./ .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} GOARM=${GOARM} go build -a -installsuffix cgo -ldflags="-s -w \
-X main.commit=$(git rev-parse HEAD) \
-X main.commit=${VCS_REF} \
-X main.version=${VERSION} \
-X main.buildSource=Docker"

FROM ${BASE_IMAGE}:${ALPINE_VERSION}
ARG VERSION=0.2.4
ARG VCS_REF=
LABEL org.label-schema.schema-version="1.0.0-rc1" \
maintainer="jessedduffield@gmail.com" \
org.label-schema.vcs-ref=$VCS_REF \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -90,6 +90,8 @@ go get github.com/jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker.git
```

You can also add `--build-arg VCS_REF=$(git rev-parse HEAD)` so that the go build and the container contain the commit used.

</p></details>
1. Run it

Expand Down

0 comments on commit fd70aaa

Please sign in to comment.