Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker fixes for arches, and tags. #1017

Merged
merged 11 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
15 changes: 15 additions & 0 deletions doc/guide/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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`
17 changes: 9 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARG branch
ARG cores
ARG configure_args
ARG packages
ARG shared

FROM ${distro}:latest as base
ARG cores
Expand All @@ -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) \
Expand All @@ -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} \
;; \
Expand All @@ -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
Expand Down
115 changes: 95 additions & 20 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -55,6 +55,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 \
Expand Down Expand Up @@ -86,6 +96,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 \
Expand All @@ -96,59 +128,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
Expand Down