diff --git a/.github/workflows/build-testflinger-testenv-container.yml b/.github/workflows/build-testflinger-testenv-container.yml new file mode 100644 index 00000000..96da9fe3 --- /dev/null +++ b/.github/workflows/build-testflinger-testenv-container.yml @@ -0,0 +1,61 @@ +name: Build testflinger-testenv container image + +on: + push: + branches: + - main + - testflinger-testenv + paths: + - agent/extra/testflinger-testenv/** + - .github/workflows/build-testflinger-testenv-container.yml + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/testflinger-testenv + +jobs: + build-testflinger-testenv: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + strategy: + matrix: + version: [focal, jammy, noble] + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + config-inline: | + [registry."docker.io"] + mirrors = ["https://github-runner-dockerhub-cache.canonical.com:5000"] + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: ${{ matrix.version }} + + - name: Build and push backend Docker image + uses: docker/build-push-action@v6 + with: + context: ./agent/extra/testflinger-testenv + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BASE_IMAGE=ubuntu:${{ matrix.version }} diff --git a/agent/extra/testflinger-testenv/Dockerfile b/agent/extra/testflinger-testenv/Dockerfile new file mode 100644 index 00000000..8b88151c --- /dev/null +++ b/agent/extra/testflinger-testenv/Dockerfile @@ -0,0 +1,12 @@ +ARG BASE_IMAGE=ubuntu:20.04 +FROM ${BASE_IMAGE} +ENV container=docker +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y expect build-essential curl jq gettext git openssh-client pipx python3-dev python3-pip python3-psutil python3-requests python3-setuptools python3-venv software-properties-common sudo sshpass virtualenv wget +RUN adduser -u 1000 --disabled-password ubuntu || /bin/true +RUN echo "ubuntu ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/ubuntu && \ + chmod 0440 /etc/sudoers.d/ubuntu +#Avoid sudo rlimit error +RUN echo "Set disable_coredump false" >> /etc/sudo.conf +USER ubuntu +WORKDIR /home/ubuntu +CMD [ "/bin/bash" ] diff --git a/agent/extra/testflinger-testenv/README b/agent/extra/testflinger-testenv/README new file mode 100644 index 00000000..3ef680e6 --- /dev/null +++ b/agent/extra/testflinger-testenv/README @@ -0,0 +1 @@ +This Dockerfile creates a basic test environment for running the test phase of testflinger agents in a Docker container.