mattermost-community / focalboard

Focalboard is an open source, self-hosted alternative to Trello, Notion, and Asana.
https://www.focalboard.com
Other
21.37k stars 1.9k forks source link

Bug: Docker build error #509

Open gabrielctn opened 3 years ago

gabrielctn commented 3 years ago

Summary: Docker build does not complete properly because of a missing package in the nodebuild layer for the Dockerfile (node:alpine image). Here is the full build output with the error at the end:

$ docker build . -t focalboard
Sending build context to Docker daemon  8.192kB
Step 1/17 : FROM golang:alpine as gobuild
alpine: Pulling from library/golang
540db60ca938: Pull complete
adcc1eea9eea: Pull complete
4c4ab2625f07: Pull complete
c5e7595549f7: Pull complete
3df88182f7ac: Pull complete
Digest: sha256:0dc62c5cc2d97657c17ff3bc0224214e10226e245c94317e352ee8a2c54368b4
Status: Downloaded newer image for golang:alpine
 ---> 722a834ff95b
Step 2/17 : RUN apk update &&     apk add ca-certificates gcc git make musl-dev &&     git clone https://github.com/mattermost/focalboard &&     cd focalboard &&     make server-linux
 ---> Running in 2e27474ab109
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
v3.13.5-150-gecf4164e08 [https://dl-cdn.alpinelinux.org/alpine/v3.13/main]
v3.13.5-159-g0fcb259c12 [https://dl-cdn.alpinelinux.org/alpine/v3.13/community]
OK: 13888 distinct packages available
(1/19) Installing libgcc (10.2.1_pre1-r3)
(2/19) Installing libstdc++ (10.2.1_pre1-r3)
(3/19) Installing binutils (2.35.2-r1)
(4/19) Installing libgomp (10.2.1_pre1-r3)
(5/19) Installing libatomic (10.2.1_pre1-r3)
(6/19) Installing libgphobos (10.2.1_pre1-r3)
(7/19) Installing gmp (6.2.1-r0)
(8/19) Installing isl22 (0.22-r0)
(9/19) Installing mpfr4 (4.1.0-r0)
(10/19) Installing mpc1 (1.2.0-r0)
(11/19) Installing gcc (10.2.1_pre1-r3)
(12/19) Installing brotli-libs (1.0.9-r3)
(13/19) Installing nghttp2-libs (1.42.0-r1)
(14/19) Installing libcurl (7.77.0-r0)
(15/19) Installing expat (2.2.10-r1)
(16/19) Installing pcre2 (10.36-r0)
(17/19) Installing git (2.30.2-r0)
(18/19) Installing make (4.3-r0)
(19/19) Installing musl-dev (1.2.2-r0)
Executing busybox-1.32.1-r6.trigger
OK: 140 MiB in 34 packages
Cloning into 'focalboard'...
mkdir -p bin/linux
cd server; env GOOS=linux GOARCH=amd64 go build -ldflags '-X "github.com/mattermost/focalboard/server/model.BuildNumber=dev" -X "github.com/mattermost/focalboard/server/model.BuildDate=Tue Jun  1 20:24:05 UTC 2021" -X "github.com/mattermost/focalboard/server/model.BuildHash=225c4bda5b47bb879c01d3d22abc1eb1b2313f6c" -X "github.com/mattermost/focalboard/server/model.Edition=linux"' -o ../bin/linux/focalboard-server ./main
go: downloading github.com/spf13/viper v1.7.1
go: downloading github.com/google/uuid v1.2.0
go: downloading github.com/mattermost/logr v1.0.13
go: downloading github.com/gorilla/mux v1.8.0
go: downloading github.com/oklog/run v1.1.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/rudderlabs/analytics-go v3.3.1+incompatible
go: downloading github.com/mattermost/mattermost-server/v5 v5.3.2-0.20210524045451-a4f7df6f6e3c
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading github.com/Masterminds/squirrel v1.5.0
go: downloading github.com/prometheus/client_golang v1.10.0
go: downloading github.com/go-sql-driver/mysql v1.5.0
go: downloading github.com/golang-migrate/migrate/v4 v4.14.1
go: downloading github.com/lib/pq v1.10.0
go: downloading github.com/mattn/go-sqlite3 v2.0.3+incompatible
go: downloading golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
go: downloading github.com/mitchellh/mapstructure v1.4.1
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading github.com/magiconair/properties v1.8.5
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/pelletier/go-toml v1.8.1
go: downloading github.com/spf13/afero v1.6.0
go: downloading github.com/spf13/cast v1.3.1
go: downloading github.com/spf13/jwalterweatherman v1.1.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/subosito/gotenv v1.2.0
go: downloading gopkg.in/ini.v1 v1.62.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading golang.org/x/sys v0.0.0-20210324051608-47abb6519492
go: downloading github.com/lann/builder v0.0.0-20180802200727-47ae307949d0
go: downloading github.com/mattermost/logr/v2 v2.0.0-20210525034931-179e4b3c986d
go: downloading github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0
go: downloading golang.org/x/text v0.3.5
go: downloading github.com/tidwall/gjson v1.7.3
go: downloading github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3
go: downloading github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c
go: downloading github.com/prometheus/common v0.20.0
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/golang/protobuf v1.5.1
go: downloading github.com/prometheus/procfs v0.6.0
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading github.com/tidwall/pretty v1.1.0
go: downloading github.com/tidwall/match v1.0.3
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/francoispqt/gojay v1.2.13
go: downloading github.com/wiggin77/merror v1.0.3
go: downloading github.com/wiggin77/srslog v1.0.1
go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading google.golang.org/protobuf v1.26.0
go: downloading github.com/minio/minio-go/v7 v7.0.10
go: downloading go.uber.org/zap v1.16.0
go: downloading github.com/wiggin77/cfg v1.0.2
go: downloading github.com/stretchr/testify v1.7.0
go: downloading github.com/mattermost/go-i18n v1.11.0
go: downloading github.com/blang/semver v3.5.1+incompatible
go: downloading github.com/pborman/uuid v1.2.1
go: downloading github.com/dyatlov/go-opengraph v0.0.0-20210112100619-dae8665a5b09
go: downloading github.com/mattermost/ldap v0.0.0-20201202150706-ee0e6284187d
go: downloading github.com/disintegration/imaging v1.6.2
go: downloading github.com/tinylib/msgp v1.1.5
go: downloading golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
go: downloading github.com/go-asn1-ber/asn1-ber v1.5.3
go: downloading github.com/philhofer/fwd v1.1.1
go: downloading go.uber.org/atomic v1.7.0
go: downloading go.uber.org/multierr v1.6.0
go: downloading github.com/json-iterator/go v1.1.10
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/minio/sha256-simd v1.0.0
go: downloading github.com/minio/md5-simd v1.1.2
go: downloading github.com/rs/xid v1.2.1
go: downloading github.com/klauspost/cpuid v1.3.1
go: downloading golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
go: downloading github.com/modern-go/reflect2 v1.0.1
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/klauspost/cpuid/v2 v2.0.5
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function 'sqlite3SelectNew':
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 |   return pNew;
       |          ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 |   Select standin;
       |          ^~~~~~~
Removing intermediate container 2e27474ab109
 ---> d3d7845e37dc
Step 3/17 : FROM node:alpine as nodebuild
alpine: Pulling from library/node
540db60ca938: Already exists
4f9832ab4c84: Pull complete
b660fdf49706: Pull complete
feaab9ebc363: Pull complete
Digest: sha256:e5615005591e2450e782fa82b10bf31e4c3a90b00f4f47f3691bcb4c03c5b1a2
Status: Downloaded newer image for node:alpine
 ---> 72ca8e2f26fa
Step 4/17 : RUN apk update &&     apk add ca-certificates git &&     git clone https://github.com/mattermost/focalboard &&     cd focalboard/webapp &&     npm install && npm run pack
 ---> Running in 38b0fad8e6ae
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
v3.13.5-150-gecf4164e08 [https://dl-cdn.alpinelinux.org/alpine/v3.13/main]
v3.13.5-159-g0fcb259c12 [https://dl-cdn.alpinelinux.org/alpine/v3.13/community]
OK: 13888 distinct packages available
(1/7) Installing ca-certificates (20191127-r5)
(2/7) Installing brotli-libs (1.0.9-r3)
(3/7) Installing nghttp2-libs (1.42.0-r1)
(4/7) Installing libcurl (7.77.0-r0)
(5/7) Installing expat (2.2.10-r1)
(6/7) Installing pcre2 (10.36-r0)
(7/7) Installing git (2.30.2-r0)
Executing busybox-1.32.1-r6.trigger
Executing ca-certificates-20191127-r5.trigger
OK: 20 MiB in 23 packages
Cloning into 'focalboard'...
npm notice
npm notice New minor version of npm available! 7.13.0 -> 7.15.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.15.1>
npm notice Run `npm install -g npm@7.15.1` to update!
npm notice
npm ERR! code 1
npm ERR! path /focalboard/webapp/node_modules/gifsicle
npm ERR! command failed
npm ERR! command sh -c node lib/install.js
npm ERR! ⚠ spawn /focalboard/webapp/node_modules/gifsicle/vendor/gifsicle ENOENT
npm ERR!   ⚠ gifsicle pre-build test failed
npm ERR!   ℹ compiling from source
npm ERR!   ✖ Error: Command failed: /bin/sh -c autoreconf -ivf
npm ERR! /bin/sh: autoreconf: not found
npm ERR!
npm ERR!
npm ERR!     at /focalboard/webapp/node_modules/bin-build/node_modules/execa/index.js:231:11
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm ERR!     at async Promise.all (index 0)

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-01T20_26_08_190Z-debug.log
The command '/bin/sh -c apk update &&     apk add ca-certificates git &&     git clone https://github.com/mattermost/focalboard &&     cd focalboard/webapp &&     npm install && npm run pack' returned a non-zero code: 1

Steps to reproduce the behavior: $ git pull https://github.com/mattermost/focalboard.git (commit 225c4bda5b47bb879c01d3d22abc1eb1b2313f6c) $ cd focalboard/docker $ docker build -t focalboard .

Expected behavior: A proper build of the docker image.

Platform: Ubuntu 20.04 x86_64

According to this post it seems like the package autoconf is missing in the nodebuild layer, but then more errors are resulting from it and I don't know how to resolve them ...

gabrielctn commented 3 years ago

I found a solution inspired by this

Replace https://github.com/mattermost/focalboard/blob/225c4bda5b47bb879c01d3d22abc1eb1b2313f6c/docker/Dockerfile#L11-L15

with

FROM node:alpine as nodebuild

RUN apk update && \
    apk add ca-certificates \
    git \
    musl-dev \
    libtool \
    zlib \
    zlib-dev \
    autoconf \
    automake \
    bash \
    g++ \
    gcc \
    musl-dev \
    libc6-compat \
    libjpeg-turbo-dev \
    libpng-dev \
    make \
    nasm && \
    git clone https://github.com/mattermost/focalboard && \
    cd focalboard/webapp && \
    npm install && npm run pack

Now docker build -t focalboard . works.