From 1b11ad4d252831a5f00cb968c22583af56a4b8f1 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Thu, 2 Jun 2022 10:37:43 +0200 Subject: [PATCH] Update Ansible, base image and remove vagrant image. (#20) --- .github/workflows/docker.yaml | 48 +++++++++++++++++++ .github/workflows/master-deployment.yaml | 41 ---------------- .github/workflows/pull_request.yaml | 45 ----------------- .github/workflows/release-deployment.yaml | 33 ------------- .github/workflows/release-drafter.yaml | 15 ++++++ .../base/Dockerfile => Dockerfile | 24 ++++++---- README.md | 8 +--- metal-deployment/base/Dockerfile.withvagrant | 22 --------- metal-deployment/base/Makefile | 17 ------- metal-deployment/base/README.md | 3 -- 10 files changed, 81 insertions(+), 175 deletions(-) create mode 100644 .github/workflows/docker.yaml delete mode 100644 .github/workflows/master-deployment.yaml delete mode 100644 .github/workflows/pull_request.yaml delete mode 100644 .github/workflows/release-deployment.yaml create mode 100644 .github/workflows/release-drafter.yaml rename metal-deployment/base/Dockerfile => Dockerfile (66%) delete mode 100644 metal-deployment/base/Dockerfile.withvagrant delete mode 100644 metal-deployment/base/Makefile delete mode 100644 metal-deployment/base/README.md diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..2622a3c --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,48 @@ +--- +name: Docker Build Action +on: + pull_request: + branches: + - master + release: + types: + - published + push: + branches: + - master + +env: + REGISTRY: ghcr.io + IMAGE_NAME: metal-deployment-base + +jobs: + build: + name: Build + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Make tag + run: | + [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true + + - name: Build and push image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.tag }} diff --git a/.github/workflows/master-deployment.yaml b/.github/workflows/master-deployment.yaml deleted file mode 100644 index 25a9fc7..0000000 --- a/.github/workflows/master-deployment.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: metal-deployment image from master - -on: - push: - branches: - - master - paths: - - 'metal-deployment/**' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: docker.io - username: ${{ secrets.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - uses: olegtarasov/get-tag@v1 - id: tagName - - - name: Build the Docker images - run: | - cd metal-deployment/base - make dockerimage - make dockerpush - - - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml deleted file mode 100644 index 5369d2e..0000000 --- a/.github/workflows/pull_request.yaml +++ /dev/null @@ -1,45 +0,0 @@ -name: metal-deployment image from pull request - -on: - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Figure out if running fork PR - id: fork - run: '["${{ secrets.DOCKER_REGISTRY_TOKEN }}" == ""] && echo "::set-output name=is_fork_pr::true" || echo "::set-output name=is_fork_pr::false"' - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - if: steps.fork.outputs.is_fork_pr == 'false' - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: docker.io - username: ${{ secrets.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - if: steps.fork.outputs.is_fork_pr == 'false' - - - name: Build the Docker images - run: | - export GITHUB_TAG_NAME=pr-${GITHUB_HEAD_REF##*/} - cd metal-deployment/base - make dockerimage - - - name: Push - run: | - export GITHUB_TAG_NAME=pr-${GITHUB_HEAD_REF##*/} - cd metal-deployment/base - make dockerpush - if: steps.fork.outputs.is_fork_pr == 'false' diff --git a/.github/workflows/release-deployment.yaml b/.github/workflows/release-deployment.yaml deleted file mode 100644 index 510868f..0000000 --- a/.github/workflows/release-deployment.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: metal-deployment image from release tag - -on: - release: - types: - - published - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: docker.io - username: ${{ secrets.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - name: Build the Docker images - run: | - export GITHUB_TAG_NAME=${GITHUB_REF##*/} - cd metal-deployment/base - make dockerimage - make dockerpush diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..da232f3 --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,15 @@ +--- +name: Release Drafter Action + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/metal-deployment/base/Dockerfile b/Dockerfile similarity index 66% rename from metal-deployment/base/Dockerfile rename to Dockerfile index dd31786..594c6ad 100644 --- a/metal-deployment/base/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ -FROM debian:bullseye +FROM debian:11-slim -ENV VERSION_ANSIBLE=4.2.0 \ +ENV VERSION_ANSIBLE=5.8.0 \ VERSION_CT=0.9.0 \ - VERSION_HELM=3.6.2 + VERSION_HELM=3.9.0 \ + CLOUD_SDK_VERSION=388.0.0 + +ENV PATH /google-cloud-sdk/bin:$PATH RUN set -x \ && apt-get update \ @@ -12,16 +15,13 @@ RUN set -x \ curl \ gnupg2 \ software-properties-common \ - && curl -f https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \ && curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \ - && add-apt-repository "deb [arch=amd64] http://packages.cloud.google.com/apt cloud-sdk-buster main" \ && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" \ && apt-get update \ && apt-get install --yes --no-install-recommends \ connect-proxy \ docker-ce \ git \ - google-cloud-sdk \ make \ openssh-client \ python3 \ @@ -29,13 +29,21 @@ RUN set -x \ python3-setuptools \ python3-wheel \ rsync \ - yamllint \ + && apt clean \ + && apt autoclean \ && ln -s /usr/bin/python3 /usr/bin/python \ && ln -s /usr/bin/python3-config /usr/bin/python-config \ && ln -s /usr/bin/python3-doc /usr/bin/python-doc \ + && curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \ + && tar xzf google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \ + && rm google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \ + && gcloud config set core/disable_usage_reporting true \ + && gcloud config set component_manager/disable_update_check true \ + && gcloud config set metrics/environment github_docker_image \ + && gcloud --version \ && curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -s -- --version "v${VERSION_HELM}" \ && python3 -m pip install --upgrade pip \ - && python3 -m pip install ansible==${VERSION_ANSIBLE} Jinja2==3.0.1 netaddr==0.8.0 humanfriendly==9.2 openshift==0.12.1 paramiko==2.7.2 \ + && python3 -m pip install ansible==${VERSION_ANSIBLE} Jinja2==3.0.1 netaddr==0.8.0 humanfriendly==9.2 openshift==0.13.1 paramiko==2.11.0 \ && curl -Lo ct https://github.com/coreos/container-linux-config-transpiler/releases/download/v${VERSION_CT}/ct-v${VERSION_CT}-x86_64-unknown-linux-gnu \ && chmod +x ct \ && mv ct /usr/local/bin/ \ diff --git a/README.md b/README.md index 0857e42..d90c33a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -# metal-stack Dockerfiles +# metal-stack deployment -This repository defines and builds some basic Dockerfiles that are used in the metal-stack. - -| Name | Description | -| --------------------- | --------------------------------------------------- | -| metal-deployment-base | Can be used when deploying metal-stack with Ansible | +This repository builds the deployment base image that can be used for deploying metal-stack with Ansible. diff --git a/metal-deployment/base/Dockerfile.withvagrant b/metal-deployment/base/Dockerfile.withvagrant deleted file mode 100644 index a55da67..0000000 --- a/metal-deployment/base/Dockerfile.withvagrant +++ /dev/null @@ -1,22 +0,0 @@ -ARG BASE_VERSION -FROM ghcr.io/metal-stack/metal-deployment-base:${BASE_VERSION} - -ENV VERSION_VAGRANT=2.2.14 - -# vagrant is required for running the vagrant dynamic inventory script from within the container... -ARG VAGRANT_PACKAGE_URL=https://releases.hashicorp.com/vagrant/${VERSION_VAGRANT}/vagrant_${VERSION_VAGRANT}_x86_64.deb - -RUN set -x \ - && apt update \ - && apt install --yes \ - gcc \ - libvirt-dev \ - make \ - ruby-dev \ - ruby-libvirt \ - && curl -fo vagrant.deb $VAGRANT_PACKAGE_URL \ - && dpkg -i vagrant.deb \ - && rm -f vagrant.deb \ - && vagrant plugin install vagrant-libvirt - -ENTRYPOINT [] diff --git a/metal-deployment/base/Makefile b/metal-deployment/base/Makefile deleted file mode 100644 index 72ee8ec..0000000 --- a/metal-deployment/base/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -DOCKER_TAG := $(or ${GITHUB_TAG_NAME}, latest) - -.PHONY: dockerimage -dockerimage: - docker build -t ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG} . - docker build --build-arg BASE_VERSION=${DOCKER_TAG} -t ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG}-vagrant . -f Dockerfile.withvagrant - -.PHONY: dockerpush -dockerpush: - docker tag ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG} metalstack/metal-deployment-base:${DOCKER_TAG} - docker tag ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG}-vagrant metalstack/metal-deployment-base:${DOCKER_TAG}-vagrant - - docker push ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG} - docker push ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG}-vagrant - - docker push metalstack/metal-deployment-base:${DOCKER_TAG} - docker push metalstack/metal-deployment-base:${DOCKER_TAG}-vagrant diff --git a/metal-deployment/base/README.md b/metal-deployment/base/README.md deleted file mode 100644 index 9ade1b0..0000000 --- a/metal-deployment/base/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Metal Deployment Base - -This image can be used for deploying metal-stack with Ansible.