Skip to content

Conversation

amalkh5
Copy link
Contributor

@amalkh5 amalkh5 commented Apr 23, 2020

Description

This commit will solve issue #92 which will show built version and SHA on start-up.

Signed-off-by: Amal Alkhamees amalkms5@gmail.com

Motivation and Context

  • I have raised an issue to propose this change (required)

How Has This Been Tested?

  1. Build the app
$ make build-armhf       
docker build --build-arg http_proxy="" --build-arg https_proxy="" --build-arg go_opts="GOARCH=arm GOARM=6" -t openfaas/queue-worker:latest-armhf .
Sending build context to Docker daemon  6.094MB
Step 1/27 : FROM golang:1.13-alpine as golang
 ---> 3369136a43d1
Step 2/27 : ENV CGO_ENABLED=0
 ---> Using cache
 ---> aa2528b92ad6
Step 3/27 : ENV GO111MODULE=off
 ---> Using cache
 ---> ee23b83c98b9
Step 4/27 : WORKDIR /go/src/github.com/openfaas/nats-queue-worker
 ---> Using cache
 ---> 312f1a317d8e
Step 5/27 : COPY vendor     vendor
 ---> Using cache
 ---> 8a1ba99e13e4
Step 6/27 : COPY handler    handler
 ---> Using cache
 ---> 4b351989c667
Step 7/27 : COPY version    version
 ---> Using cache
 ---> e0583954c890
Step 8/27 : COPY nats       nats
 ---> Using cache
 ---> 156a910dde5f
Step 9/27 : COPY main.go  .
 ---> 1b74c670c7cc
Step 10/27 : COPY types.go .
 ---> 31e6914ec333
Step 11/27 : COPY readconfig.go .
 ---> 02e747d8b9a3
Step 12/27 : COPY readconfig_test.go .
 ---> 90c5147c19b4
Step 13/27 : COPY auth.go .
 ---> 4012d8aa241c
Step 14/27 : COPY .git     .
 ---> f353cd3a75e6
Step 15/27 : ARG go_opts
 ---> Running in 907f32fdae6a
Removing intermediate container 907f32fdae6a
 ---> c6ab9981df73
Step 16/27 : RUN apk add --no-cache git
 ---> Running in 01a6d50fff12
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/5) Installing nghttp2-libs (1.40.0-r0)
(2/5) Installing libcurl (7.67.0-r0)
(3/5) Installing expat (2.2.9-r1)
(4/5) Installing pcre2 (10.34-r1)
(5/5) Installing git (2.24.3-r0)
Executing busybox-1.31.1-r9.trigger
OK: 22 MiB in 20 packages
Removing intermediate container 01a6d50fff12
 ---> 7f7bd6942c1c
Step 17/27 : RUN  VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///')     && GIT_COMMIT=$(git rev-list -1 HEAD)     && env $go_opts CGO_ENABLED=0 go build         --ldflags "-s -w         -X github.com/openfaas/nats-queue-worker/version.GitCommit=${GIT_COMMIT}        -X github.com/openfaas/nats-queue-worker/version.Version=${VERSION}"         -a -installsuffix cgo -o app .     && addgroup -S app     && adduser -S -g app app     && mkdir /scratch-tmp
 ---> Running in 05c7dadb99e5
Removing intermediate container 05c7dadb99e5
 ---> 6e17f5d37444
Step 18/27 : FROM scratch
 ---> 
Step 19/27 : EXPOSE 8080
 ---> Using cache
 ---> dbb3305e45bf
Step 20/27 : ENV http_proxy      ""
 ---> Using cache
 ---> c0c061819d6e
Step 21/27 : ENV https_proxy     ""
 ---> Using cache
 ---> c042be336103
Step 22/27 : USER app
 ---> Using cache
 ---> a313f1ea1e99
Step 23/27 : COPY --from=golang /etc/passwd /etc/group /etc/
 ---> Using cache
 ---> 25b6a012f427
Step 24/27 : COPY --from=golang /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
 ---> Using cache
 ---> b4dbd26dec0b
Step 25/27 : COPY --from=golang --chown=app:app /scratch-tmp /tmp
 ---> Using cache
 ---> a6959de22414
Step 26/27 : COPY --from=golang /go/src/github.com/openfaas/nats-queue-worker/app    .
 ---> b4ee64cb047c
Step 27/27 : CMD ["./app"]
 ---> Running in 7ae8bb6be5d3
Removing intermediate container 7ae8bb6be5d3
 ---> fdb55c62cf8a
Successfully built fdb55c62cf8a                      
Successfully tagged openfaas/queue-worker:latest-armhf
  1. Run the app
$ docker run openfaas/queue-worker:latest-armhf
Starting Queue worker.
Version: 0.10.1
Git Commit: 1f4e16e1f7afe1fbd464fcaa8a7dabaa3e4ef0bb
Connect: nats://nats:4222
can't connect to nats://nats:4222: nats: no servers available for connection
panic: can't connect to nats://nats:4222: nats: no servers available for connection
goroutine 1 [running]:
log.Panic(0x85beac, 0x1, 0x1)
        /usr/local/go/src/log/log.go:338 +0x84
main.main()
        /go/src/github.com/openfaas/nats-queue-worker/main.go:219 +0x4d8

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on naming

Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment

Signed-off-by: Amal Alkhamees <amalkms5@gmail.com>
@amalkh5
Copy link
Contributor Author

amalkh5 commented Apr 23, 2020

@alexellis fixed.

Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@alexellis
Copy link
Member

Thank you for this PR. 👍

@alexellis alexellis merged commit de4adf2 into openfaas:master May 12, 2020
@amalkh5 amalkh5 deleted the issue-92 branch May 12, 2020 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants