magma / magma

Platform for building access networks and modular network services
https://www.magmacore.org/
Other
1.69k stars 608 forks source link

Use bazel-base image as basis for Bazel builds in Dockerfiles #14903

Open LKreutzer opened 1 year ago

LKreutzer commented 1 year ago

Use bazel-base image as basis for Bazel builds in Dockerfiles

E.g. in lte/gateway/docker/services/c/Dockerfile a new Docker image is built from Focal, in which a Bazel build happens. Having many different Docker files is hard to maintain. If all Bazel builds are based on the bazel-base Docker image then the same conditions and system dependencies are used for all builds. It may also speed up the workflows.

I.e. in lte/gateway/docker/services/c/Dockerfile, instead of doing

FROM $OS_DIST:$OS_RELEASE AS builder
...
...
  # Setup necessary tools for adding the Magma repository
  apt-get install -y apt-utils software-properties-common apt-transport-https gnupg wget && \
  # Download Bazel
  wget -P /usr/sbin --progress=dot:giga https://github.com/bazelbuild/bazelisk/releases/download/v1.10.0/bazelisk-linux-"${DEB_PORT}" && \
  chmod +x /usr/sbin/bazelisk-linux-"${DEB_PORT}" && \
  ln -s /usr/sbin/bazelisk-linux-"${DEB_PORT}" /usr/sbin/bazel

# Install dependencies required for building
...

simply do

FROM ghcr.io/magma/magma/bazel-base:latest AS builder
...
bazel build ...
LKreutzer commented 1 year ago

⚠ It needs to be ensured that the build is also possible on ARM, which is difficult with the current bazel-base image.