Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
Update Dockerfiles and gofmt
Browse files Browse the repository at this point in the history
- apply gofmt where missing
- update Dockerfiles to match for each architecture and bump
ship image to Alpine 3.10, and download license-check via the
utility script for multi-arch

Signed-off-by: Alex Ellis <[email protected]>
  • Loading branch information
alexellis committed Jul 31, 2019
1 parent c7c7a19 commit 9dac977
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
FROM golang:1.11 as build
RUN curl -sLSf https://raw.githubusercontent.com/teamserverless/license-check/master/get.sh | sh
RUN mv ./license-check /usr/bin/license-check && chmod +x /usr/bin/license-check

RUN mkdir -p /go/src/github.com/openfaas/faas-swarm/

WORKDIR /go/src/github.com/openfaas/faas-swarm

COPY . .

RUN curl -sL https://github.com/alexellis/license-check/releases/download/0.2.2/license-check > /usr/bin/license-check \
&& chmod +x /usr/bin/license-check
RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Author(s)"
RUN license-check -path /go/src/github.com/openfaas/faas-swarm/ --verbose=false "Alex Ellis" "OpenFaaS Author(s)"

RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") \
&& go test $(go list ./... | grep -v /vendor/) -cover \
&& CGO_ENABLED=0 go test $(go list ./... | grep -v /vendor/) -cover \
&& VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/openfaas/faas-swarm/version.GitCommit=${GIT_COMMIT}\
-X github.com/openfaas/faas-swarm/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-swarm .

# Release stage
FROM alpine:3.8
FROM alpine:3.10 as ship

LABEL org.label-schema.license="MIT" \
org.label-schema.vcs-url="https://github.com/openfaas/faas-swarm" \
Expand Down
35 changes: 20 additions & 15 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
# Build stage
FROM golang:1.10.4 as build
FROM golang:1.11 as build
RUN curl -sLSf https://raw.githubusercontent.com/teamserverless/license-check/master/get.sh | sh
RUN mv ./license-check /usr/bin/license-check && chmod +x /usr/bin/license-check

RUN mkdir -p /go/src/github.com/openfaas/faas-swarm/

WORKDIR /go/src/github.com/openfaas/faas-swarm

COPY . .

#RUN curl -sL https://github.com/alexellis/license-check/releases/download/0.2.2/license-check > /usr/bin/license-check \
# && chmod +x /usr/bin/license-check
#RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Author(s)"
RUN license-check -path /go/src/github.com/openfaas/faas-swarm/ --verbose=false "Alex Ellis" "OpenFaaS Author(s)"

RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") \
&& go test $(go list ./... | grep -v /vendor/) -cover \
&& VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/openfaas/faas-swarm/version.GitCommit=${GIT_COMMIT}\
-X github.com/openfaas/faas-swarm/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-swarm .

# Release stage
FROM alpine:3.8
&& CGO_ENABLED=0 go test $(go list ./... | grep -v /vendor/) -cover \
&& VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/openfaas/faas-swarm/version.GitCommit=${GIT_COMMIT}\
-X github.com/openfaas/faas-swarm/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-swarm .

FROM alpine:3.10 as ship

LABEL org.label-schema.license="MIT" \
org.label-schema.vcs-url="https://github.com/openfaas/faas-swarm" \
org.label-schema.vcs-type="Git" \
org.label-schema.name="openfaas/faas-swarm" \
org.label-schema.vendor="openfaas" \
org.label-schema.docker.schema-version="1.0"

RUN apk --no-cache add ca-certificates

Expand Down
35 changes: 20 additions & 15 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
# Build stage
FROM golang:1.9.7 as build
FROM golang:1.11 as build
RUN curl -sLSf https://raw.githubusercontent.com/teamserverless/license-check/master/get.sh | sh
RUN mv ./license-check /usr/bin/license-check && chmod +x /usr/bin/license-check

RUN mkdir -p /go/src/github.com/openfaas/faas-swarm/

WORKDIR /go/src/github.com/openfaas/faas-swarm

COPY . .

#RUN curl -sL https://github.com/alexellis/license-check/releases/download/0.2.2/license-check > /usr/bin/license-check \
# && chmod +x /usr/bin/license-check
#RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Author(s)"
RUN license-check -path /go/src/github.com/openfaas/faas-swarm/ --verbose=false "Alex Ellis" "OpenFaaS Author(s)"

RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") \
&& go test $(go list ./... | grep -v /vendor/) -cover \
&& VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& GOARM=6 CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/openfaas/faas-swarm/version.GitCommit=${GIT_COMMIT}\
-X github.com/openfaas/faas-swarm/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-swarm .

# Release stage
FROM alpine:3.7
&& CGO_ENABLED=0 go test $(go list ./... | grep -v /vendor/) -cover \
&& VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/openfaas/faas-swarm/version.GitCommit=${GIT_COMMIT}\
-X github.com/openfaas/faas-swarm/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-swarm .

FROM alpine:3.10 as ship

LABEL org.label-schema.license="MIT" \
org.label-schema.vcs-url="https://github.com/openfaas/faas-swarm" \
org.label-schema.vcs-type="Git" \
org.label-schema.name="openfaas/faas-swarm" \
org.label-schema.vendor="openfaas" \
org.label-schema.docker.schema-version="1.0"

RUN apk --no-cache add ca-certificates

Expand Down
2 changes: 1 addition & 1 deletion handlers/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Test_BuildLabels_NoAnnotations(t *testing.T) {
func Test_BuildLabels_KeyClash(t *testing.T) {
request := &requests.CreateFunctionRequest{
Labels: &map[string]string{
"function_name": "echo",
"function_name": "echo",
fmt.Sprintf("%scurrent-time", annotationLabelPrefix): "foo",
},
Annotations: &map[string]string{"current-time": "Wed 25 Jul 06:41:43 BST 2018"},
Expand Down
3 changes: 1 addition & 2 deletions handlers/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func updateSecret(c client.SecretAPIClient, body []byte) (responseStatus int, re
)
}

return http.StatusOK, nil,nil
return http.StatusOK, nil, nil
}

func deleteSecret(c client.SecretAPIClient, body []byte) (responseStatus int, responseBody []byte, err error) {
Expand Down Expand Up @@ -256,7 +256,6 @@ func deleteSecret(c client.SecretAPIClient, body []byte) (responseStatus int, re
return http.StatusOK, nil, nil
}


func makeSecretsArray(c *client.Client, secretNames []string) ([]*swarm.SecretReference, error) {
values := []*swarm.SecretReference{}

Expand Down

0 comments on commit 9dac977

Please sign in to comment.