diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 47ace58149..167e70f076 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -25,5 +25,7 @@ jobs: - name: Push to Docker Hub on Pushes to master run: | docker login -u gerbil -p ${{ secrets.DOCKER_TOKEN }} - docker push gerbil/${{ matrix.docker-image }}:$(uname -m) + docker push gerbil/${{ matrix.docker-image }}:$(uname -m)-master + docker manifest create gerbil/${{ matrix.docker-image }}:master --amend gerbil/gerbil:aarch64-master --amend gerbil/gerbil:x86_64-master + docker manifest push gerbil/${{ matrix.docker-image }}:master if: github.event_name == 'push' diff --git a/doc/guide/docker.md b/doc/guide/docker.md index 97a8a31eaa..9b87ea78bb 100644 --- a/doc/guide/docker.md +++ b/doc/guide/docker.md @@ -7,6 +7,9 @@ We offer two official docker images based on Alpine Linux: - `gerbilxx` is the full image, configured without shared libraries and with C++ enabled. It also includes all the foreign dependencies required by the officially supported external packages. +- Supported architectures are `aarch64` and `x86_64`. +- `:latest` always points at the last release, e.g. `v0.18` +- `:master` points to the latest merge into the `master` branch. Alpine was chosen due to the static compilation environment and capabilities it provides. @@ -60,3 +63,15 @@ clean: install: mv .gerbil/bin/$(PROJECT) /usr/local/bin/$(PROJECT) ``` + +## Building docker images + +There are several variations you can build out on docker. + +### Build using custom branch + +`cd gerbil/docker && make gerbil BRANCH=my-fixup-branch` + +### Building from your own repository + +`cd gerbil/docker && make gerbil REPO=my-github-user/gerbil` diff --git a/docker/Dockerfile b/docker/Dockerfile index 374adae2a2..2643677655 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,6 +5,7 @@ ARG branch ARG cores ARG configure_args ARG packages +ARG shared FROM ${distro}:latest as base ARG cores @@ -14,7 +15,6 @@ ARG packages ENV PATH=/opt/gerbil/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin ENV GERBIL_BUILD_CORES=$cores ENV DEBIAN_FRONTEND=noninteractive -ENV GERBIL_GCC=g++ RUN mkdir -p /src /opt RUN case ${distro} in \ alpine) \ @@ -32,7 +32,7 @@ RUN case ${distro} in \ yum update -y && yum groupinstall -y 'Development Tools' && \ eval yum install -y ${packages} \ ;; \ - ubuntu) \ + debian|ubuntu) \ apt update -y && \ eval apt install -y ${packages} \ ;; \ @@ -43,15 +43,16 @@ RUN case ${distro} in \ esac FROM base as gerbil -ARG cores -ARG repo ARG branch ARG configure_args -ENV GERBIL_GCC=g++ -RUN cd /opt && eval git clone -b "${branch}" "https://github.com/${repo}" gerbil-src \ - && cd /opt/gerbil-src && eval ./configure --prefix=/opt/gerbil --enable-shared=no ${configure_args} +ARG cores +ARG repo +ARG shared +RUN cd /opt && eval git clone -b "${branch}" "https://github.com/${repo}" gerbil-src \ + && cd /opt/gerbil-src && eval ./configure --prefix=/opt/gerbil --enable-shared=${shared} ${configure_args} -RUN cd /opt/gerbil-src && make && make install +RUN cd /opt/gerbil-src && make +RUN cd /opt/gerbil-src && make install FROM gerbil as final RUN rm -rf /opt/gerbil-src /src/leveldb /src/lmdb diff --git a/docker/Makefile b/docker/Makefile index f0313dc429..4ce668f54f 100755 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,4 +1,4 @@ -.PHONY: alpine amazonlinux ubuntu fedora ubuntu-current-jedi final +.PHONY: alpine amazonlinux debian ubuntu fedora ubuntu-current-jedi final ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) cores := $(shell nproc) @@ -56,6 +56,16 @@ amazon_packages := cmake \ openssl-devel \ sqlite-devel +centos_packages := cmake \ + git \ + leveldb-devel \ + libsqlite3x-devel \ + libxml2-devel \ + libyaml-devel \ + lmdb-devel \ + openssl-devel \ + sqlite-devel + fedora_packages := cmake \ leveldb-devel \ libsqlite3x-devel \ @@ -87,6 +97,28 @@ ubuntu_packages := autoconf \ texinfo \ zlib1g-dev +debian_packages := autoconf \ + bison \ + build-essential \ + curl \ + gawk \ + git \ + libleveldb-dev \ + libleveldb1d \ + liblmdb-dev \ + libnss3-dev \ + libsnappy1v5 \ + libsqlite3-dev \ + libssl-dev \ + libxml2-dev \ + libyaml-dev \ + pkg-config \ + python3 \ + rsync \ + rubygems \ + texinfo \ + zlib1g-dev + gerbilxx: docker build --target final \ --rm=true --no-cache \ @@ -97,59 +129,102 @@ gerbilxx: --build-arg configure_args="--enable-c++ --enable-march=" \ --build-arg cores=$(cores) \ --build-arg with_db="YES" \ - --build-arg distro="alpine" -t final $(ROOT_DIR) \ + --build-arg distro="alpine" \ + --build-arg shared="no" \ + -t final $(ROOT_DIR) \ --progress=plain - docker tag final gerbil/gerbilxx:$(arch) + docker tag final gerbil/gerbilxx:$(arch)-$(BRANCH) gerbil: docker build --target final \ --rm=true --no-cache \ - --build-arg repo="$(REPO)" \ --build-arg branch="$(BRANCH)" \ - --build-arg packages="$(alpine_packages)" \ --build-arg configure_args="--enable-march=" \ --build-arg cores=$(cores) \ - --build-arg distro="alpine" -t final $(ROOT_DIR) \ + --build-arg distro="alpine" \ + --build-arg packages="$(alpine_packages)" \ + --build-arg repo="$(REPO)" \ + --build-arg shared="no" \ + -t final $(ROOT_DIR) \ --progress=plain - docker tag final gerbil/gerbil:$(arch) + docker tag final gerbil/gerbil:$(arch)-$(BRANCH) amazonlinux: docker build --target final \ + --rm=true --no-cache \ + --build-arg branch="$(BRANCH)" \ + --build-arg configure_args="--enable-c++ --enable-march=" \ + --build-arg cores=$(cores) \ + --build-arg distro="amazonlinux" \ --build-arg gerbil_version=$(GERBIL_VERSION) \ --build-arg packages="$(amazon_packages)" \ - --build-arg cores=$(cores) \ - --build-arg distro="amazonlinux" \ + --build-arg repo="$(REPO)" \ + --build-arg shared="yes" \ + --build-arg with_db="YES" \ -t final $(ROOT_DIR) - docker tag final gerbil/amazonlinux:$(arch) + docker tag final gerbil/amazonlinux:$(arch)-$(BRANCH) centos: docker build --target final \ --rm=true --no-cache \ - --build-arg gerbil_version=$(GERBIL_VERSION) \ - --build-arg packages="$(centos_packages)" \ + --build-arg branch="$(BRANCH)" \ + --build-arg configure_args="--enable-c++ --enable-march=" \ --build-arg cores=$(cores) \ --build-arg distro="centos" \ + --build-arg gerbil_version=$(GERBIL_VERSION) \ + --build-arg packages="$(centos_packages)" \ + --build-arg repo="$(REPO)" \ + --build-arg shared="yes" \ + --build-arg with_db="YES" \ -t final $(ROOT_DIR) - docker tag final gerbil/centos:$(arch) + docker tag final gerbil/centos:$(arch)-$(BRANCH) fedora: docker build --target final \ - --build-arg gerbil_version=$(GERBIL_VERSION) \ - --build-arg packages="$(fedora_packages)" \ + --build-arg branch="$(BRANCH)" \ + --build-arg configure_args="--enable-c++ --enable-march=" \ --build-arg cores=$(cores) \ --build-arg distro="fedora" \ - -t final $(ROOT_DIR) - docker tag final gerbil/fedora:$(arch) + --build-arg gerbil_version=$(GERBIL_VERSION) \ + --build-arg packages="$(fedora_packages)" \ + --build-arg repo="$(REPO)" \ + --build-arg shared="yes" \ + --build-arg with_db="YES" \ + -t final $(ROOT_DIR) \ + --progress=plain + docker tag final gerbil/fedora:$(arch)-$(BRANCH) ubuntu: docker build --target final \ --rm=true --no-cache \ + --build-arg branch="$(BRANCH)" \ + --build-arg configure_args="--enable-c++ --enable-march=" \ + --build-arg cores=$(cores) \ + --build-arg distro="ubuntu" \ --build-arg gerbil_version=$(GERBIL_VERSION) \ --build-arg packages="$(ubuntu_packages)" \ + --build-arg repo="$(REPO)" \ + --build-arg shared="yes" \ + --build-arg with_db="YES" \ + -t final $(ROOT_DIR) \ + --progress=plain + docker tag final gerbil/ubuntu:$(arch)-$(BRANCH) + +debian: + docker build --target final \ + --rm=true --no-cache \ + --build-arg branch="$(BRANCH)" \ + --build-arg configure_args="--enable-c++ --enable-march=" \ --build-arg cores=$(cores) \ - --build-arg distro="ubuntu" \ - -t final $(ROOT_DIR) - docker tag final gerbil/ubuntu:$(arch) + --build-arg distro="debian" \ + --build-arg gerbil_version=$(GERBIL_VERSION) \ + --build-arg packages="$(debian_packages)" \ + --build-arg repo="$(REPO)" \ + --build-arg shared="yes" \ + --build-arg with_db="YES" \ + -t final $(ROOT_DIR) \ + --progress=plain + docker tag final gerbil/ubuntu:$(arch)-$(BRANCH) ubuntu-current-jedi: docker build --rm=true --no-cache -t ubuntu-current-jedi $(ROOT_DIR)/ubuntu-current-jedi