Skip to content

Commit a786cf1

Browse files
committed
build: fix the image to work with golangci-lint
In #195 I updated the Go version, and also swapped from Debian to Alpine for the base image. This was OK for the build, but it turns out we also use the same image to run golangci-lint. That action uses a binary for a different architecture, which fails on this image. So: - Keep the Go version, but revert the base image. - Split image layers to make rebuilds faster. - Add version labels as arguments. - Add some documentation to the workflow configs.
1 parent 8882f27 commit a786cf1

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
1515

1616
Test:
17+
# The custom image here contains pre-built libraries for leveldb and
18+
# rocksdb, which are needed to build and test those modules.
19+
# To update the container image, see docker.yml.
1720
runs-on: ubuntu-latest
1821
container: tendermintdev/docker-tm-db-testing
1922
steps:

.github/workflows/docker.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# This workflow builds and pushes a new version of the build container image
2+
# when the tools directory changes on master. Edit tools/Dockerfile.
3+
#
4+
# This workflow does not push a new image until it is merged, so tests that
5+
# depend on changes in this image will not pass until this workflow succeeds.
6+
# For that reason, changes here should be done in a separate PR in advance of
7+
# work that depends on them.
8+
19
name: Build & Push TM-DB-Testing
210
on:
311
pull_request:

.github/workflows/lint.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ on:
77

88
jobs:
99
golangci:
10+
# We need to run the linter on the same image we use for building, since it
11+
# needs the C libraries installed for the dependencies to typecheck.
1012
runs-on: ubuntu-latest
1113
container: tendermintdev/docker-tm-db-testing
1214
steps:
1315
- uses: actions/checkout@v2
1416
- uses: golangci/[email protected]
1517
with:
16-
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
18+
# Required: the version of golangci-lint is required and must be
19+
# specified without patch version: we always use the latest patch
20+
# version.
1721
version: v1.30
1822
args: --timeout 10m
1923
github-token: ${{ secrets.github_token }}

tools/Dockerfile

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,43 @@
1-
FROM golang:1.16-alpine
1+
# This file defines the container image used to build and test tm-db in CI.
2+
# The CI workflows use the latest tag of tendermintdev/docker-tm-db-testing
3+
# built from these settings.
4+
#
5+
# The jobs defined in the Build & Push workflow will build and update the image
6+
# when changes to this file are merged. If you have other changes that require
7+
# updates here, merge the changes here first and let the image get updated (or
8+
# push a new version manually) before PRs that depend on them.
9+
10+
FROM golang:1.17-alpine AS build
211

312
ENV LD_LIBRARY_PATH=/usr/local/lib
413

514
RUN apk add bash build-base bzip2-dev gflags-dev linux-headers \
615
perl snappy-dev util-linux wget zlib-dev zstd-dev
716

17+
FROM build AS install
18+
ARG LEVELDB=1.20
19+
ARG ROCKSDB=6.24.2
20+
821
# Install cleveldb
922
RUN \
10-
wget -q https://github.com/google/leveldb/archive/v1.20.tar.gz \
11-
&& tar xvf v1.20.tar.gz \
12-
&& cd leveldb-1.20 \
23+
wget -q https://github.com/google/leveldb/archive/v${LEVELDB}.tar.gz \
24+
&& tar xvf v${LEVELDB}.tar.gz \
25+
&& cd leveldb-${LEVELDB} \
1326
&& make \
1427
&& cp -a out-static/lib* out-shared/lib* /usr/local/lib \
1528
&& cd include \
1629
&& cp -a leveldb /usr/local/include \
1730
&& ldconfig $LD_LIBRARY_PATH \
1831
&& cd ../.. \
19-
&& rm -rf v1.20.tar.gz leveldb-1.20
32+
&& rm -rf v${LEVELDB}.tar.gz leveldb-${LEVELDB}
2033

2134
# Install Rocksdb
2235
RUN \
23-
wget -q https://github.com/facebook/rocksdb/archive/v6.6.4.tar.gz \
24-
&& tar -zxf v6.6.4.tar.gz \
25-
&& cd rocksdb-6.6.4 \
26-
&& sed -i'' 's/install -C/install -c/g' Makefile \
36+
wget -q https://github.com/facebook/rocksdb/archive/v${ROCKSDB}.tar.gz \
37+
&& tar -zxf v${ROCKSDB}.tar.gz \
38+
&& cd rocksdb-${ROCKSDB} \
2739
&& DEBUG_LEVEL=0 make -j4 shared_lib \
2840
&& make install-shared \
2941
&& ldconfig $LD_LIBRARY_PATH \
3042
&& cd .. \
31-
&& rm -rf v6.6.4.tar.gz rocksdb-6.6.4
43+
&& rm -rf v${ROCKSDB}.tar.gz rocksdb-${ROCKSDB}

0 commit comments

Comments
 (0)