bazel: add builder container

Co-authored-by: Malte Poll <mp@edgeless.systems>
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-04-13 14:23:59 +02:00
parent c3c068b65e
commit caedb1c081
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,34 @@
# syntax=docker/dockerfile:1.5-labs
FROM fedora:37
ARG TARGETOS
ARG TARGETARCH
ARG BAZEL_VERSION=6.1.0
ARG BAZELISK_VERSION=v1.16.0
ARG BAZELISK_SHA256=168851e70cf5f95c0e215e7f3aaca5132ffc3c8dd8f585a4157b0be2b53cfe32
ADD --checksum=sha256:${BAZELISK_SHA256} \
https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-${TARGETOS}-${TARGETARCH} \
/usr/local/bin/bazelisk
RUN chmod +x /usr/local/bin/bazelisk && \
ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel && \
dnf install -y \
git \
diffutils \
&& \
dnf clean all && \
groupadd --gid 1000 builder && \
useradd -rm -d /home/builder -s /bin/bash -g root -u 1000 --gid builder builder && \
mkdir -p /home/builder/.cache && \
mkdir -p /workspace && \
chown -R builder:builder /home/builder/.cache /workspace && \
git config --global --add safe.directory /workspace
USER builder
WORKDIR /workspace
RUN git config --global --add safe.directory /workspace && \
USE_BAZEL_VERSION=${BAZEL_VERSION} bazel version
ENTRYPOINT [ "/usr/local/bin/bazel" ]

12
bazel/container/Makefile Normal file
View File

@ -0,0 +1,12 @@
export DOCKER_BUILDKIT=1
CONTAINER_NAME := ghcr.io/edgelesssys/bazel-container
CONTAINER_VERSION := v6.1.0-0
.PHONY: container container-push
container:
docker build -f Containerfile -t "$(CONTAINER_NAME):$(CONTAINER_VERSION)" .
container-push:
docker push "$(CONTAINER_NAME):$(CONTAINER_VERSION)"