File tree Expand file tree Collapse file tree 5 files changed +24
-36
lines changed Expand file tree Collapse file tree 5 files changed +24
-36
lines changed Original file line number Diff line number Diff line change 1- FROM golang:alpine
1+ ARG BASE=1.9.3-alpine3.7
2+ FROM golang:${BASE} as build
23
4+ WORKDIR /usr/src/app
5+
6+ COPY engine.json ./engine.json.template
7+ RUN apk add --no-cache jq
8+ RUN export go_version=$(go version | cut -d ' ' -f 3) && \
9+ cat engine.json.template | jq '.version = .version + "/" + env.go_version' > ./engine.json
10+
11+ COPY codeclimate-gofmt.go ./
12+ RUN apk add --no-cache git
13+ RUN go get -t -d -v .
14+ RUN go build -o codeclimate-gofmt .
15+
16+
17+ FROM golang:${BASE}
318LABEL maintainer="Code Climate <hello@codeclimate.com>"
419
520RUN adduser -u 9000 -D app
621
722WORKDIR /usr/src/app
823
9- COPY engine.json /engine.json
10- COPY codeclimate-gofmt.go ./
11- RUN apk add --no-cache --virtual .dev-deps git && \
12- go get -t -d -v . && \
13- go build -o codeclimate-gofmt . && \
14- rm -r $GOPATH/src/* && \
15- apk del .dev-deps
24+ COPY --from=build /usr/src/app/engine.json /
25+ COPY --from=build /usr/src/app/codeclimate-gofmt ./
1626
1727USER app
1828
Original file line number Diff line number Diff line change 1- .PHONY : update image
1+ .PHONY : image
22
33IMAGE_NAME ?= codeclimate/codeclimate-gofmt
44
5- update :
6- docker run \
7- --rm --interactive \
8- -v $(PWD ) /engine.json:/engine.json \
9- -v $(PWD ) /bin/update:/usr/local/bin/update \
10- golang:alpine \
11- /usr/local/bin/update
12-
135image :
146 docker build --tag " $( IMAGE_NAME) " .
Original file line number Diff line number Diff line change @@ -27,15 +27,10 @@ This will build a `codeclimate/codeclimate-gofmt` image locally.
2727# ## Updating
2828
2929` gofmt` is a part of the Go distribution and shares version with it. Once in a
30- while a new version of Go gets packaged and in order to get the latest version
31- and force a new docker image build, we have to update the `engine.json` file.
32-
33- ` ` ` console
34- make update
35- ` ` `
36-
37- This will update engine version with the latest `gofmt` version. After that
38- rebuild the image as usually.
30+ while a new version of Go gets packaged. In order to get the latest version
31+ and force a new docker image build, please update the base image in the
32+ ` Dockerfile` . Please avoid any unstable tags such as `latest` and keep it
33+ explicit.
3934
4035# ## Need help?
4136
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 88 "languages" : [
99 " Go"
1010 ],
11- "version" : " 1.0.0/go-1.8.4-r0 " ,
11+ "version" : " 1.0.0" ,
1212 "spec_version" : " 0.3.1"
1313}
You can’t perform that action at this time.
0 commit comments