Skip to content

Commit

Permalink
Add Dockerfile with builder image
Browse files Browse the repository at this point in the history
  • Loading branch information
mvukov committed Nov 1, 2023
1 parent 968d9c5 commit 5e4745c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ci

on:
push:
branches:
- 'main'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: mvukov/bazel-builder:commit-${{ github.sha }}
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive

ARG BAZELISK_VER=1.17.0
ARG GCC_VER=11
ARG CLANG_VER=14

RUN apt update && apt-get install -y \
clang-$CLANG_VER \
curl \
gcc-$GCC_VER \
g++-$GCC_VER \
libatomic1 \
python3

RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-$CLANG_VER 100 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$CLANG_VER 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-$GCC_VER 100 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VER 100

RUN curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64" -o /usr/local/bin/bazelisk \
&& chmod +x /usr/local/bin/bazelisk \
&& ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel

# Based on https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
ARG USERNAME=ci
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME

0 comments on commit 5e4745c

Please sign in to comment.