Merge pull request #834 from linuxserver/universal-docker-in-docker-multi

dind: switch to multi-arch
This commit is contained in:
aptalca
2024-02-14 14:22:37 -05:00
committed by GitHub
3 changed files with 40 additions and 36 deletions
+4
View File
@@ -7,6 +7,7 @@ env:
ENDPOINT: "linuxserver/mods" #don't modify ENDPOINT: "linuxserver/mods" #don't modify
BASEIMAGE: "universal" #replace BASEIMAGE: "universal" #replace
MODNAME: "docker-in-docker" #replace MODNAME: "docker-in-docker" #replace
MULTI_ARCH: "true" #set to true if needed
jobs: jobs:
set-vars: set-vars:
@@ -19,6 +20,7 @@ jobs:
echo "ENDPOINT=${{ env.ENDPOINT }}" >> $GITHUB_OUTPUT echo "ENDPOINT=${{ env.ENDPOINT }}" >> $GITHUB_OUTPUT
echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
echo "MULTI_ARCH=${{ env.MULTI_ARCH }}" >> $GITHUB_OUTPUT
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. **** # **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
COMPOSE_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/compose/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||') COMPOSE_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/compose/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||')
DOCKER_RELEASE=$(curl -sX GET "https://api.github.com/repos/moby/moby/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||') DOCKER_RELEASE=$(curl -sX GET "https://api.github.com/repos/moby/moby/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||')
@@ -29,6 +31,7 @@ jobs:
ENDPOINT: ${{ steps.outputs.outputs.ENDPOINT }} ENDPOINT: ${{ steps.outputs.outputs.ENDPOINT }}
BASEIMAGE: ${{ steps.outputs.outputs.BASEIMAGE }} BASEIMAGE: ${{ steps.outputs.outputs.BASEIMAGE }}
MODNAME: ${{ steps.outputs.outputs.MODNAME }} MODNAME: ${{ steps.outputs.outputs.MODNAME }}
MULTI_ARCH: ${{ steps.outputs.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ steps.outputs.outputs.MOD_VERSION }} MOD_VERSION: ${{ steps.outputs.outputs.MOD_VERSION }}
build: build:
@@ -44,4 +47,5 @@ jobs:
ENDPOINT: ${{ needs.set-vars.outputs.ENDPOINT }} ENDPOINT: ${{ needs.set-vars.outputs.ENDPOINT }}
BASEIMAGE: ${{ needs.set-vars.outputs.BASEIMAGE }} BASEIMAGE: ${{ needs.set-vars.outputs.BASEIMAGE }}
MODNAME: ${{ needs.set-vars.outputs.MODNAME }} MODNAME: ${{ needs.set-vars.outputs.MODNAME }}
MULTI_ARCH: ${{ needs.set-vars.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ needs.set-vars.outputs.MOD_VERSION }} MOD_VERSION: ${{ needs.set-vars.outputs.MOD_VERSION }}
+32 -32
View File
@@ -1,13 +1,13 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
## Buildstage ## ## Buildstage ##
FROM ghcr.io/linuxserver/baseimage-alpine:3.17 as buildstage FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage
ARG MOD_VERSION ARG MOD_VERSION
RUN \ RUN \
echo "**** retrieve latest version ****" && \ echo "**** retrieve latest version ****" && \
if [[ -z "${MOD_VERSION+x}" ]]; then \ if [ -z "${MOD_VERSION+x}" ]; then \
DOCKER_RELEASE=$(curl -sX GET "https://api.github.com/repos/moby/moby/releases/latest" \ DOCKER_RELEASE=$(curl -sX GET "https://api.github.com/repos/moby/moby/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]' \ | awk '/tag_name/{print $4;exit}' FS='[""]' \
| sed 's|^v||'); \ | sed 's|^v||'); \
@@ -18,47 +18,47 @@ RUN \
DOCKER_RELEASE=$(echo "${MOD_VERSION}" | sed 's|-.*||'); \ DOCKER_RELEASE=$(echo "${MOD_VERSION}" | sed 's|-.*||'); \
COMPOSE_RELEASE=$(echo "${MOD_VERSION}" | sed 's|.*-||'); \ COMPOSE_RELEASE=$(echo "${MOD_VERSION}" | sed 's|.*-||'); \
fi && \ fi && \
echo "**** grab docker ****" && \
mkdir -p /root-layer/docker-tgz && \
curl -fo \
/root-layer/docker-tgz/docker_x86_64.tgz -L \
"https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_RELEASE}.tgz" && \
curl -fo \
/root-layer/docker-tgz/docker_aarch64.tgz -L \
"https://download.docker.com/linux/static/stable/aarch64/docker-${DOCKER_RELEASE}.tgz" && \
echo "**** grab compose ****" && \
curl -fo \
/root-layer/docker-tgz/docker-compose_x86_64 -L \
"https://github.com/docker/compose/releases/download/v${COMPOSE_RELEASE}/docker-compose-linux-x86_64" && \
curl -fo \
/root-layer/docker-tgz/docker-compose_aarch64 -L \
"https://github.com/docker/compose/releases/download/v${COMPOSE_RELEASE}/docker-compose-linux-aarch64" && \
echo "**** retrieve latest compose switch version ****" && \ echo "**** retrieve latest compose switch version ****" && \
SWITCH_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/compose-switch/releases/latest" \ SWITCH_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/compose-switch/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]' \ | awk '/tag_name/{print $4;exit}' FS='[""]' \
| sed 's|^v||') && \ | sed 's|^v||') && \
echo "**** grab compose switch ****" && \
curl -fo \
/root-layer/docker-tgz/compose-switch_x86_64 -L \
"https://github.com/docker/compose-switch/releases/download/v${SWITCH_RELEASE}/docker-compose-linux-amd64" && \
curl -fo \
/root-layer/docker-tgz/compose-switch_aarch64 -L \
"https://github.com/docker/compose-switch/releases/download/v${SWITCH_RELEASE}/docker-compose-linux-arm64" && \
echo "**** retrieve latest buildx version ****" && \ echo "**** retrieve latest buildx version ****" && \
BUILDX_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/buildx/releases/latest" \ BUILDX_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/buildx/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]') && \ | awk '/tag_name/{print $4;exit}' FS='[""]') && \
echo "**** grab buildx ****" && \ mkdir -p /root-layer/docker-tgz && \
curl -fo \ if [ $(uname -m) = "x86_64" ]; then \
/root-layer/docker-tgz/docker-buildx_x86_64 -L \ echo "**** grab x86_64 tarballs and binaries ****" && \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-amd64" && \ curl -fo \
curl -fo \ /root-layer/docker-tgz/docker.tgz -L \
/root-layer/docker-tgz/docker-buildx_aarch64 -L \ "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_RELEASE}.tgz" && \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-arm64" && \ curl -fo \
/root-layer/docker-tgz/docker-compose -L \
"https://github.com/docker/compose/releases/download/v${COMPOSE_RELEASE}/docker-compose-linux-x86_64" && \
curl -fo \
/root-layer/docker-tgz/compose-switch -L \
"https://github.com/docker/compose-switch/releases/download/v${SWITCH_RELEASE}/docker-compose-linux-amd64" && \
curl -fo \
/root-layer/docker-tgz/docker-buildx -L \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-amd64"; \
elif [ $(uname -m) = "aarch64" ]; then \
echo "**** grab aarch64 tarballs and binaries ****" && \
curl -fo \
/root-layer/docker-tgz/docker.tgz -L \
"https://download.docker.com/linux/static/stable/aarch64/docker-${DOCKER_RELEASE}.tgz" && \
curl -fo \
/root-layer/docker-tgz/docker-compose -L \
"https://github.com/docker/compose/releases/download/v${COMPOSE_RELEASE}/docker-compose-linux-aarch64" && \
curl -fo \
/root-layer/docker-tgz/compose-switch -L \
"https://github.com/docker/compose-switch/releases/download/v${SWITCH_RELEASE}/docker-compose-linux-arm64" && \
curl -fo \
/root-layer/docker-tgz/docker-buildx -L \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-arm64"; \
fi && \
chmod +x /root-layer/docker-tgz/* && \ chmod +x /root-layer/docker-tgz/* && \
rm -rf /tmp/* rm -rf /tmp/*
# copy local files # copy local files
COPY root/ /root-layer/ COPY root/ /root-layer/
@@ -41,10 +41,10 @@ fi
if [ -d "/docker-tgz" ] ; then if [ -d "/docker-tgz" ] ; then
echo "Copying over docker and docker-compose binaries" echo "Copying over docker and docker-compose binaries"
mkdir -p /usr/local/lib/docker/cli-plugins mkdir -p /usr/local/lib/docker/cli-plugins
mv "/docker-tgz/docker-compose_${ARCH}" /usr/local/lib/docker/cli-plugins/docker-compose mv "/docker-tgz/docker-compose" /usr/local/lib/docker/cli-plugins/docker-compose
mv "/docker-tgz/docker-buildx_${ARCH}" /usr/local/lib/docker/cli-plugins/docker-buildx mv "/docker-tgz/docker-buildx" /usr/local/lib/docker/cli-plugins/docker-buildx
mv "/docker-tgz/compose-switch_${ARCH}" /usr/local/bin/docker-compose mv "/docker-tgz/compose-switch" /usr/local/bin/docker-compose
tar xf /docker-tgz/docker_${ARCH}.tgz \ tar xf /docker-tgz/docker.tgz \
--strip-components=1 -C \ --strip-components=1 -C \
/usr/local/bin/ /usr/local/bin/
rm -rf /docker-tgz rm -rf /docker-tgz