Skip to content

Commit

Permalink
Build static binaries for Docker, so that we can use 'scratch' image (#…
Browse files Browse the repository at this point in the history
…1766)

* Build static binaries for Docker, so that we can use the 'stratch' image.
* add changelog entry
  • Loading branch information
ylebre authored Jun 14, 2021
1 parent 1ca0cfc commit 07adb3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ ci: build-ci test lint-ci

# to be run in Docker build
build-revad-docker: off
go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad
env CGO_ENABLED=0 go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad
build-reva-docker: off
go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva
env CGO_ENABLED=0 go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva
clean:
rm -rf dist

Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/set-cgo-enabled-0-flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Set CGO_ENABLED flag for 'scratch' based docker builds

The CGO_ENABLED=0 flag was added to the docker build flags so that it will
produce a static build. This allows usage of the 'scratch' image for
reduction of the docker image size.

https://github.com/cs3org/reva/issues/1765
https://github.com/cs3org/reva/pull/1766

4 comments on commit 07adb3f

@Daniel-WWU-IT
Copy link
Contributor

Choose a reason for hiding this comment

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

This change results in the following errors on our deployment:

2021-06-22 11:01:18.305 ERR cmd/revad/runtime/runtime.go:205 > error starting the grpc server error="unable to register services: rgrpc: grpc service storageprovider could not be started,: localfs: error initializing db: localfs: error preparing statement: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub" pid=1
2021-06-22 11:01:18.305 ERR cmd/revad/runtime/runtime.go:197 > error starting the http server error="http service dataprovider could not be started,: localfs: error initializing db: localfs: error preparing statement: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub" pid=1
2021-06-22 11:01:18.305 INF cmd/revad/internal/grace/grace.go:89 > pid file "/var/run/revad.pid" got removed pid=1 pkg=grace
2021-06-22 11:01:18.305 WRN cmd/revad/internal/grace/grace.go:87 > error removing pid file error="remove /var/run/revad.pid: no such file or directory" pid=1 pkg=grace

@labkode
Copy link
Member

@labkode labkode commented on 07adb3f Jun 22, 2021

Choose a reason for hiding this comment

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

@SamuAlfageme
@Daniel-WWU-IT
I just merged this one and I think it fixes this issue:
#1797

@SamuAlfageme
Copy link
Contributor

Choose a reason for hiding this comment

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

@Daniel-WWU-IT can you give revad:latest a try? Apologies for the hiccup.

@Daniel-WWU-IT
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that has fixed the issue!

Please sign in to comment.