diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index c0cde64..0821d69 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -7,7 +7,7 @@ on: jobs: docker-build: - if: ${{ github.ref == 'refs/heads/main' && contains('["chaddyc"]', github.actor) }} + # if: ${{ github.ref == 'refs/heads/main' && contains('["chaddyc"]', github.actor) }} runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ github.token }} @@ -28,41 +28,32 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push ubuntu 22.04 amd64 + - name: Build and push ubuntu 22.04 uses: docker/build-push-action@v6 with: - context: amd64.Dockerfile - platforms: linux/amd64 - build-arg: UBUNTU_VERSION=22.04-amd64 + file: Dockerfile + platforms: linux/amd64,linux/arm64 + build-arg: UBUNTU_VERSION=22.04 push: true - tags: chaddyc/${{ github.event.repository.name }}:22.04-amd64 + tags: chaddyc/${{ github.event.repository.name }}:22.04 - - name: Build and push ubuntu 22.04 arm64 + - name: Build and push ubuntu 24.04 uses: docker/build-push-action@v6 with: - context: arm64.Dockerfile - platforms: linux/arm64 - build-arg: UBUNTU_VERSION=22.04-ARM64 + context: . + platforms: linux/amd64,linux/arm64 + build-arg: UBUNTU_VERSION=24.04 push: true - tags: chaddyc/${{ github.event.repository.name }}:22.04 - - # - name: Build and push ubuntu 24.04 - # uses: docker/build-push-action@v6 - # with: - # context: . - # platforms: linux/amd64,linux/arm64 - # build-arg: UBUNTU_VERSION=24.04 - # push: true - # tags: chaddyc/${{ github.event.repository.name }}:24.04 + tags: chaddyc/${{ github.event.repository.name }}:24.04 - # - name: Build and push ubuntu latest - # uses: docker/build-push-action@v6 - # with: - # context: . - # platforms: linux/amd64,linux/arm64 - # build-arg: UBUNTU_VERSION=latest - # push: true - # tags: chaddyc/${{ github.event.repository.name }}:latest + - name: Build and push ubuntu latest + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-arg: UBUNTU_VERSION=latest + push: true + tags: chaddyc/${{ github.event.repository.name }}:latest - name: Update docker readme description uses: peter-evans/dockerhub-description@v3 diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 0000000..251092f --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,64 @@ +name: Docker Test + +on: + pull_request: + branches: + - main + + +jobs: + docker-build: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ github.token }} + REPO: ${{ github.event.repository.name }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEM + 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.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push ubuntu 22.04 + uses: docker/build-push-action@v6 + with: + file: Dockerfile + platforms: linux/amd64,linux/arm64 + build-arg: UBUNTU_VERSION=22.04 + push: false + tags: chaddyc/${{ github.event.repository.name }}:22.04 + + - name: Build and push ubuntu 24.04 + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-arg: UBUNTU_VERSION=24.04 + push: false + tags: chaddyc/${{ github.event.repository.name }}:24.04 + + - name: Build and push ubuntu latest + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-arg: UBUNTU_VERSION=latest + push: false + tags: chaddyc/${{ github.event.repository.name }}:latest + + - name: Update docker readme description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: chaddyc/${{ github.event.repository.name }} + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2abfe5f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +ARG UBUNTU_VERSION=20.04 +FROM ubuntu:${UBUNTU_VERSION} +LABEL org.opencontainers.image.authors="https://github.com/chaddyc" + +ARG TARGETARCH +RUN echo "Detected architecture: ${TARGETARCH}" + +ENV RUNNER_ARCH=${RUNNER_ARCH} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + curl \ + jq \ + git \ + tar \ + sudo \ + software-properties-common && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /runner + +RUN LATEST_RUNNER_VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | jq -r .tag_name) && \ + RUNNER_VERSION_NUMBER=$(echo "$LATEST_RUNNER_VERSION" | sed 's/^v//') && \ + if [ "${TARGETARCH}" = "amd64" ]; then \ + export RUNNER_ARCH="x64"; \ + elif [ "${TARGETARCH}" = "arm64" ]; then \ + export RUNNER_ARCH="arm64"; \ + else \ + echo "Unsupported architecture: ${TARGETARCH}"; exit 1; \ + fi && \ + echo "Downloading https://github.com/actions/runner/releases/download/$LATEST_RUNNER_VERSION/actions-runner-linux-$RUNNER_ARCH-$RUNNER_VERSION_NUMBER.tar.gz" && \ + curl -L -o actions-runner.tar.gz https://github.com/actions/runner/releases/download/$LATEST_RUNNER_VERSION/actions-runner-linux-$RUNNER_ARCH-$RUNNER_VERSION_NUMBER.tar.gz && \ + tar xzf actions-runner.tar.gz && \ + rm -f actions-runner.tar.gz + +RUN ./bin/installdependencies.sh + +RUN useradd -m -s /bin/bash runner && \ + echo "runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +RUN chown -R runner:runner /runner + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +USER runner +WORKDIR /runner + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/amd64.Dockerfile b/docker/amd64.Dockerfile similarity index 100% rename from amd64.Dockerfile rename to docker/amd64.Dockerfile diff --git a/amr64.Dockerfile b/docker/arm64.Dockerfile similarity index 100% rename from amr64.Dockerfile rename to docker/arm64.Dockerfile