From f519f9d60b7a3f2cf49dccc32e8f203ef17fa474 Mon Sep 17 00:00:00 2001 From: Whisperity Date: Wed, 22 May 2024 11:38:29 +0200 Subject: [PATCH] feat(ci): Build the Docker image in GitHub Actions CI --- .dockerignore | 3 +++ .github/workflows/docker-image.yml | 30 ++++++++++++++++++++++++++++++ Dockerfile | 10 ++++++---- usr/local/sbin/container-main.sh | 2 +- 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker-image.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2b5cc14 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +LICENSE +README.md diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..afb4730 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,30 @@ +name: "Docker Image CI" + +on: + push: + pull_request: + +jobs: + build: + env: + RUNS_ON: "ubuntu-20.04" + runs-on: "ubuntu-20.04" + steps: + - name: "Build Docker Image" + uses: docker/build-push-action@v5 + with: + load: true + tags: "distcc-docker:${{ env.RUNS_ON }}" + - name: "Simple test" + run: | + docker run \ + --init \ + --rm \ + "distcc-docker:${{ env.RUNS_ON }}" + --jobs $(nproc) \ + -- \ + bash -c \ + "ps fauxw; " \ + "/usr/bin/ls -alh .; " \ + "/usr/bin/ls -alh /var/log; " \ + "cat /var/log/*;" diff --git a/Dockerfile b/Dockerfile index cd898f3..ea3553f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,13 +32,11 @@ ENV \ LC_ALL="en_US.UTF-8" -COPY etc/ /etc/ -COPY usr/ /usr/ - - # Set to non-zero if the compilers should only be installed into the container, # and not immediately baked into the image itself. ARG LAZY_COMPILERS=0 + +COPY usr/local/sbin/install-compilers.sh /usr/local/sbin/install-compilers.sh RUN \ if [ "x$LAZY_COMPILERS" = "x0" ]; \ then \ @@ -67,6 +65,10 @@ RUN echo "Creating service user: $USERNAME ..." >&2 && \ chmod -v 444 "/var/lib/distcc/distcc.user" +COPY etc/ /etc/ +COPY usr/ /usr/ + + # Expose the DistCC server's normal job and statistics subservice port. # Custom ports to be used on the host machine should be managed via Docker. EXPOSE \ diff --git a/usr/local/sbin/container-main.sh b/usr/local/sbin/container-main.sh index 7d65179..0e21552 100755 --- a/usr/local/sbin/container-main.sh +++ b/usr/local/sbin/container-main.sh @@ -317,7 +317,7 @@ if [ "$EXEC_CUSTOM" -eq 1 ]; then echo "[...] distcc service is running." >&2 fi - custom_command $@ + custom_command "$@" EXIT_CODE=$? atexit