Skip to content

Commit

Permalink
feat: adding building runner (#529)
Browse files Browse the repository at this point in the history
Co-authored-by: Luka Skugor <[email protected]>
  • Loading branch information
NikolaMilosa and LittleChimera authored Jun 25, 2024
1 parent 63690eb commit 2864b49
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-runner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and push runner image

on:
push:
branches:
- "main"
paths:
- "docker/runner.Dockerfile"
- "docker/runner.Dockerfile.dockerignore"
- ".github/workflows/build-runner.yaml"
pull_request:
paths:
- "docker/runner.Dockerfile"
- "docker/runner.Dockerfile.dockerignore"
- ".github/workflows/build-runner.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: "🔧 Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Copy requirements.txt"
run: cp requirements.txt docker
shell: bash

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./docker
file: ./docker/runner.Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/dfinity/dre/actions-runner:${{ github.sha }}
19 changes: 17 additions & 2 deletions docker/runner.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ ENV RUNNER_UID=1001

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install ca-certificates curl git-all gcc g++ clang pkg-config make sudo docker.io build-essential -y
apt-get install ca-certificates curl git-all gcc g++ clang pkg-config make sudo docker.io build-essential \
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libffi-dev liblzma-dev libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl -y

RUN mkdir -p openssl && \
curl -o openssl/openssl-1.1.1w.tar.gz -L https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz && \
Expand All @@ -23,6 +25,19 @@ RUN ln -s /usr/local/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1 && \
ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1 && \
rm -rf openssl

RUN mkdir python3.12 && \
curl -o python3.12/Python-3.12.0.tar.xz -L https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz && \
tar -xzvf python3.12/Python-3.12.0.tar.xz -C python3.12 && \
cd python3.12/Python-3.12.0 && \
./configure --enable-optimizations && \
make -j 8 && \
make altinstall && \
ln -s python3.12 /usr/local/bin/python && \
ln -s pip3.12 /usr/local/bin/pip

COPY requirements.txt .
RUN pip install -r requirements.txt

# Runner user
RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \
&& usermod -aG sudo runner \
Expand All @@ -31,4 +46,4 @@ RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \
&& echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers
ENV HOME=/home/runner
USER runner
WORKDIR /home/runner
WORKDIR /home/runner
2 changes: 2 additions & 0 deletions docker/runner.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!requirements.txt

0 comments on commit 2864b49

Please sign in to comment.