From 1d7a4c59854a4f3a79c38841f69181398e03d1aa Mon Sep 17 00:00:00 2001 From: Samuel Alfageme Sainz Date: Tue, 15 Jun 2021 17:51:00 +0200 Subject: [PATCH 1/2] Revert "Build static binaries for Docker, so that we can use 'scratch' image (#1766)" This partially reverts commit 07adb3f0eb4ad678d09e5ba48800abce59ad5480 as there are a few issues when trying to run revad e.g. go-sqlite3 requires it: 2021-06-15 15:39:31.314 ERR go/src/github/cs3org/reva/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 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7a1206a715..ac75c7485d 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ ci: build-ci test lint-ci # to be run in Docker build build-revad-docker: off - env CGO_ENABLED=0 go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad + go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad build-reva-docker: off env CGO_ENABLED=0 go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva clean: From 5582b1807c3889b9ab007b818497c43b05958128 Mon Sep 17 00:00:00 2001 From: Samuel Alfageme Sainz Date: Wed, 16 Jun 2021 12:25:05 +0200 Subject: [PATCH 2/2] Docker: use 'golang:alpine' base & install mailcap for mime-type support Update changelog to reflect this --- Dockerfile.revad | 5 ++++- changelog/unreleased/set-cgo-enabled-0-flag.md | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Dockerfile.revad b/Dockerfile.revad index fec40722bf..7d6dbc5d3c 100644 --- a/Dockerfile.revad +++ b/Dockerfile.revad @@ -36,7 +36,10 @@ RUN make build-revad-docker && \ RUN mkdir -p /etc/revad/ && echo "" > /etc/revad/revad.toml -FROM scratch +FROM golang:alpine + +RUN apk --no-cache add \ + mailcap EXPOSE 9999 10000 diff --git a/changelog/unreleased/set-cgo-enabled-0-flag.md b/changelog/unreleased/set-cgo-enabled-0-flag.md index 5ea66fc500..f7295ec06a 100644 --- a/changelog/unreleased/set-cgo-enabled-0-flag.md +++ b/changelog/unreleased/set-cgo-enabled-0-flag.md @@ -1,8 +1,13 @@ -Bugfix: Set CGO_ENABLED flag for 'scratch' based docker builds +Bugfix: 'golang:alpine' as base image & CGO_ENABLED just for the CLI + +Some of the dependencies used by revad need CGO to be enabled in order to +work. We also need to install the 'mime-types' in alpine to correctly +detect them on the storage-providers. 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. +reduction of the docker image size (e.g. the reva cli). https://github.com/cs3org/reva/issues/1765 -https://github.com/cs3org/reva/pull/1766 \ No newline at end of file +https://github.com/cs3org/reva/pull/1766 +https://github.com/cs3org/reva/pull/1797