Skip to content

Instantly share code, notes, and snippets.

@jleach
Created December 12, 2022 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jleach/6b7d7608bbff8e44a9539f811fa08836 to your computer and use it in GitHub Desktop.
Save jleach/6b7d7608bbff8e44a9539f811fa08836 to your computer and use it in GitHub Desktop.
Andible runner image that will work for ARM64 and AMD64 architecture
FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/ubi:latest
ENV TINI_VERSION=v0.19.0
ENV KUBESEAL_VERSION=v0.19.2
ENV KUSTOMIZE_VERSION=v4.5.7
ENV HELM_VERSION=v3.10.2
ARG TARGETARCH
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /bin/tini
ADD bin/entrypoint.sh /bin/entrypoint
RUN dnf install -y git hostname jq python3 python3-pip && \
pip3 install --upgrade pip && \
pip install ansible molecule yamllint flake8 ansible-lint openshift kubernetes jq pyjwt jmespath && \
chmod +x /bin/tini /bin/entrypoint && \
rm -rf /var/cache/dnf
RUN curl -LOJ https://github.com/bitnami-labs/sealed-secrets/releases/download/${KUBESEAL_VERSION}/kubeseal-linux-${TARGETARCH} && \
mv kubeseal-linux-${TARGETARCH} /bin/kubeseal && \
chmod +x /bin/kubeseal
RUN curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz | \
tar -xz && \
mv kustomize /bin/kustomize
RUN curl -L https://get.helm.sh/helm-${HELM_VERSION}-linux-${TARGETARCH}.tar.gz | \
tar -xz && \
mv linux-${TARGETARCH}/helm /bin/helm
ENV HOME=/ansible
RUN mkdir -p ${HOME} ${HOME}/.ansible/tmp
COPY . /ansible
RUN chmod -R g+w ${HOME} && chgrp -R root ${HOME}
WORKDIR /ansible
ENTRYPOINT ["entrypoint"]
CMD ["sleep", "infinity"]
@jleach
Copy link
Author

jleach commented Dec 12, 2022

To build for both platforms you can use:
docker buildx build --platform=linux/amd64,linux/arm64 --push -t fullboar/gitops-runner:v0.2.0 .

The --push arg expects a registry where it can push to. You can't (as of yet) load multi-architecture image into your local repository. If you want to use it locally build for the architecture of your current platform with:

docker buildx build --platform=linux/arm64 --load -t gitops-runner:v0.2.0 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment