From e303888014ac7c3e35f99192ac1f80786c207c33 Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Tue, 24 Nov 2020 10:51:04 +0100 Subject: [PATCH 1/7] split into two images, save almost 1GB for our most used image --- metal-deployment/base/Dockerfile | 46 ++++++++------------ metal-deployment/base/Dockerfile.withvagrant | 22 ++++++++++ metal-deployment/base/Makefile | 2 + 3 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 metal-deployment/base/Dockerfile.withvagrant diff --git a/metal-deployment/base/Dockerfile b/metal-deployment/base/Dockerfile index bbdbcb8..c2150c1 100644 --- a/metal-deployment/base/Dockerfile +++ b/metal-deployment/base/Dockerfile @@ -1,49 +1,39 @@ -FROM python:3.8-buster +FROM debian:10 -ENV VERSION_ANSIBLE=2.9.13 \ +ENV VERSION_ANSIBLE=2.9.15 \ VERSION_CT=0.9.0 \ - VERSION_HELM=3.4.0 \ - VERSION_STERN=1.11.0 \ - VERSION_VAGRANT=2.2.9 - -# 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 + VERSION_HELM=3.4.0 RUN set -x \ - && export CLOUD_SDK_REPO="cloud-sdk-buster" \ - && echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \ - && curl -f https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \ && apt-get update \ && apt-get install --yes --no-install-recommends \ apt-transport-https \ ca-certificates \ curl \ gnupg2 \ - google-cloud-sdk \ software-properties-common \ - connect-proxy \ - libvirt-dev \ - ruby-dev \ - rsync \ - yamllint \ + && 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 docker-ce \ + && apt-get install --yes --no-install-recommends \ + google-cloud-sdk \ + docker-ce \ + connect-proxy \ + python3 \ + python3-pip \ + python3-setuptools \ + python3-wheel \ + rsync \ + yamllint \ && curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -s -- --version "v${VERSION_HELM}" \ - && pip install --upgrade pip \ - && pip install ansible==${VERSION_ANSIBLE} Jinja2==2.11.1 netaddr==0.7.19 humanfriendly==8.1 openshift==0.11.2 paramiko==2.7.1 \ - && curl -fo vagrant.deb $VAGRANT_PACKAGE_URL \ - && dpkg -i vagrant.deb \ - && rm -f vagrant.deb \ - && vagrant plugin install vagrant-libvirt \ - && curl -Lo stern https://github.com/wercker/stern/releases/download/${VERSION_STERN}/stern_linux_amd64 \ - && chmod +x stern \ - && mv stern /usr/local/bin/ \ + && pip3 install ansible==${VERSION_ANSIBLE} Jinja2==2.11.1 netaddr==0.7.19 humanfriendly==8.1 openshift==0.11.2 paramiko==2.7.1 \ && 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/ \ && curl -fsSL https://dl.minio.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc \ - && chmod +x /usr/local/bin/mc + && chmod +x /usr/local/bin/mc \ + && rm -rf /var/cache/apt/* /tmp/* ENTRYPOINT [] diff --git a/metal-deployment/base/Dockerfile.withvagrant b/metal-deployment/base/Dockerfile.withvagrant new file mode 100644 index 0000000..a55da67 --- /dev/null +++ b/metal-deployment/base/Dockerfile.withvagrant @@ -0,0 +1,22 @@ +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 index 1a7e6e9..9343c59 100644 --- a/metal-deployment/base/Makefile +++ b/metal-deployment/base/Makefile @@ -3,7 +3,9 @@ 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-vagrant:${DOCKER_TAG} . -f Dockerfile.withvagrant .PHONY: dockerpush dockerpush: docker push ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG} + docker push ghcr.io/metal-stack/metal-deployment-base-vagrant:${DOCKER_TAG} From 5a83b67643784bfd7340d26101f06c66217406d2 Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Tue, 24 Nov 2020 12:13:26 +0100 Subject: [PATCH 2/7] Install pip link and prepend -vagrant --- metal-deployment/base/Dockerfile | 1 + metal-deployment/base/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/metal-deployment/base/Dockerfile b/metal-deployment/base/Dockerfile index c2150c1..955b8d8 100644 --- a/metal-deployment/base/Dockerfile +++ b/metal-deployment/base/Dockerfile @@ -27,6 +27,7 @@ RUN set -x \ python3-wheel \ rsync \ yamllint \ + && ln -s /usr/bin/pip3 /usr/bin/pip \ && curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -s -- --version "v${VERSION_HELM}" \ && pip3 install ansible==${VERSION_ANSIBLE} Jinja2==2.11.1 netaddr==0.7.19 humanfriendly==8.1 openshift==0.11.2 paramiko==2.7.1 \ && 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 \ diff --git a/metal-deployment/base/Makefile b/metal-deployment/base/Makefile index 9343c59..e48290c 100644 --- a/metal-deployment/base/Makefile +++ b/metal-deployment/base/Makefile @@ -3,9 +3,9 @@ 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-vagrant:${DOCKER_TAG} . -f Dockerfile.withvagrant + 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 push ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG} - docker push ghcr.io/metal-stack/metal-deployment-base-vagrant:${DOCKER_TAG} + docker push ghcr.io/metal-stack/metal-deployment-base:${DOCKER_TAG}-vagrant From 16273c111bb4766f5593c197fff859d67b1bbaab Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 25 Nov 2020 14:26:40 +0100 Subject: [PATCH 3/7] add git and make --- metal-deployment/base/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/metal-deployment/base/Dockerfile b/metal-deployment/base/Dockerfile index 955b8d8..3475493 100644 --- a/metal-deployment/base/Dockerfile +++ b/metal-deployment/base/Dockerfile @@ -18,9 +18,11 @@ RUN set -x \ && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" \ && apt-get update \ && apt-get install --yes --no-install-recommends \ - google-cloud-sdk \ - docker-ce \ connect-proxy \ + docker-ce \ + git \ + google-cloud-sdk \ + make \ python3 \ python3-pip \ python3-setuptools \ From 10a9b335e6820893fad0ddf30f455cf8529066f1 Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 25 Nov 2020 14:48:30 +0100 Subject: [PATCH 4/7] python brainfuck --- metal-deployment/base/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/metal-deployment/base/Dockerfile b/metal-deployment/base/Dockerfile index 3475493..26ccfb8 100644 --- a/metal-deployment/base/Dockerfile +++ b/metal-deployment/base/Dockerfile @@ -29,6 +29,7 @@ RUN set -x \ python3-wheel \ rsync \ yamllint \ + && ln -s /usr/bin/python /usr/bin/python3 \ && ln -s /usr/bin/pip3 /usr/bin/pip \ && curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -s -- --version "v${VERSION_HELM}" \ && pip3 install ansible==${VERSION_ANSIBLE} Jinja2==2.11.1 netaddr==0.7.19 humanfriendly==8.1 openshift==0.11.2 paramiko==2.7.1 \ From fdd19f9d27f762a204b007ef4b4a08721b9c94df Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 25 Nov 2020 15:12:49 +0100 Subject: [PATCH 5/7] python brainfuck --- metal-deployment/base/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metal-deployment/base/Dockerfile b/metal-deployment/base/Dockerfile index 26ccfb8..c965d05 100644 --- a/metal-deployment/base/Dockerfile +++ b/metal-deployment/base/Dockerfile @@ -29,7 +29,7 @@ RUN set -x \ python3-wheel \ rsync \ yamllint \ - && ln -s /usr/bin/python /usr/bin/python3 \ + && ln -s /usr/bin/python3 /usr/bin/python \ && ln -s /usr/bin/pip3 /usr/bin/pip \ && curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -s -- --version "v${VERSION_HELM}" \ && pip3 install ansible==${VERSION_ANSIBLE} Jinja2==2.11.1 netaddr==0.7.19 humanfriendly==8.1 openshift==0.11.2 paramiko==2.7.1 \ From 2d2937a8848d2fa6ca3ff4d2b7b5c2e87f8f3f6d Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 25 Nov 2020 15:27:06 +0100 Subject: [PATCH 6/7] create all brainfuck python links --- metal-deployment/base/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metal-deployment/base/Dockerfile b/metal-deployment/base/Dockerfile index c965d05..639b19e 100644 --- a/metal-deployment/base/Dockerfile +++ b/metal-deployment/base/Dockerfile @@ -29,8 +29,10 @@ RUN set -x \ python3-wheel \ rsync \ yamllint \ - && ln -s /usr/bin/python3 /usr/bin/python \ && ln -s /usr/bin/pip3 /usr/bin/pip \ + && 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 -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -s -- --version "v${VERSION_HELM}" \ && pip3 install ansible==${VERSION_ANSIBLE} Jinja2==2.11.1 netaddr==0.7.19 humanfriendly==8.1 openshift==0.11.2 paramiko==2.7.1 \ && 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 \ From 01b170a4723fbda9d6f240148e2c97019c9a4f21 Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 25 Nov 2020 16:29:00 +0100 Subject: [PATCH 7/7] add ssh client --- metal-deployment/base/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/metal-deployment/base/Dockerfile b/metal-deployment/base/Dockerfile index 639b19e..d971163 100644 --- a/metal-deployment/base/Dockerfile +++ b/metal-deployment/base/Dockerfile @@ -23,6 +23,7 @@ RUN set -x \ git \ google-cloud-sdk \ make \ + openssh-client \ python3 \ python3-pip \ python3-setuptools \