From 0f5ca96bbe2d9fe609e03b4591f95e2acbf12468 Mon Sep 17 00:00:00 2001 From: Richard Gee Date: Sat, 19 Jan 2019 17:54:10 +0000 Subject: [PATCH] Add build-args to Dockerfile.armhf When the /system/info endpoint was expanded to include information about the gateway a number of build-args were added to the main Dockerfile. These changes were not mirrored in Dockerfile.armhf, which resulted in nil attributes and an ugly error when running `faas version` against an armhf gateway. This change carries the changes made to Dockerfile through to Dockerfile.armhf. As well as the build-args which fix the identified issue the license check has also been added at the latest release 0.2.3, as a armhf build has been made available. Further changes are to introduce the app user and moving the binary location from /root/ to /home/app/ Signed-off-by: Richard Gee --- gateway/Dockerfile.armhf | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/gateway/Dockerfile.armhf b/gateway/Dockerfile.armhf index bae443da..a2abf10d 100644 --- a/gateway/Dockerfile.armhf +++ b/gateway/Dockerfile.armhf @@ -1,4 +1,11 @@ FROM golang:1.10.4 as build +ARG GIT_COMMIT_SHA +ARG GIT_COMMIT_MESSAGE +ARG VERSION='dev' + +RUN curl -sSfL https://github.com/alexellis/license-check/releases/download/0.2.3/license-check-armhf \ + > /usr/bin/license-check \ + && chmod +x /usr/bin/license-check WORKDIR /go/src/github.com/openfaas/faas/gateway @@ -16,17 +23,39 @@ COPY version version COPY scaling scaling COPY server.go . -RUN GOARM=7 CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway . +# Run a gofmt and exclude all vendored code. +RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Project" "OpenFaaS Authors" "OpenFaaS Author(s)" \ + && test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" \ + && go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover \ + && GOARM=7 CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \ + -X github.com/openfaas/faas/gateway/version.GitCommitSHA=${GIT_COMMIT_SHA}\ + -X \"github.com/openfaas/faas/gateway/version.GitCommitMessage=${GIT_COMMIT_MESSAGE}\"\ + -X github.com/openfaas/faas/gateway/version.Version=${VERSION}" \ + -a -installsuffix cgo -o gateway . FROM alpine:3.8 -WORKDIR /root/ + +LABEL org.label-schema.license="MIT" \ + org.label-schema.vcs-url="https://github.com/openfaas/faas" \ + org.label-schema.vcs-type="Git" \ + org.label-schema.name="openfaas/faas" \ + org.label-schema.vendor="openfaas" \ + org.label-schema.docker.schema-version="1.0" + +RUN addgroup -S app \ + && adduser -S -g app app + +WORKDIR /home/app EXPOSE 8080 ENV http_proxy "" ENV https_proxy "" -COPY --from=0 /go/src/github.com/openfaas/faas/gateway/gateway . +COPY --from=build /go/src/github.com/openfaas/faas/gateway/gateway . COPY assets assets -RUN sed -ie s/store.json/store-armhf.json/g /root/assets/script/funcstore.js +RUN sed -ie s/store.json/store-armhf.json/g /home/app/assets/script/funcstore.js +RUN chown -R app:app ./ +USER app + CMD ["./gateway"]