Skip to content

Commit

Permalink
Merge pull request #834 from linuxserver/universal-docker-in-docker-m…
Browse files Browse the repository at this point in the history
…ulti

dind: switch to multi-arch
  • Loading branch information
aptalca authored Feb 14, 2024
2 parents 5b556c3 + c7fdd5f commit e202c69
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/BuildImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
ENDPOINT: "linuxserver/mods" #don't modify
BASEIMAGE: "universal" #replace
MODNAME: "docker-in-docker" #replace
MULTI_ARCH: "true" #set to true if needed

jobs:
set-vars:
Expand All @@ -19,6 +20,7 @@ jobs:
echo "ENDPOINT=${{ env.ENDPOINT }}" >> $GITHUB_OUTPUT
echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $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. ****
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||')
Expand All @@ -29,6 +31,7 @@ jobs:
ENDPOINT: ${{ steps.outputs.outputs.ENDPOINT }}
BASEIMAGE: ${{ steps.outputs.outputs.BASEIMAGE }}
MODNAME: ${{ steps.outputs.outputs.MODNAME }}
MULTI_ARCH: ${{ steps.outputs.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ steps.outputs.outputs.MOD_VERSION }}

build:
Expand All @@ -44,4 +47,5 @@ jobs:
ENDPOINT: ${{ needs.set-vars.outputs.ENDPOINT }}
BASEIMAGE: ${{ needs.set-vars.outputs.BASEIMAGE }}
MODNAME: ${{ needs.set-vars.outputs.MODNAME }}
MULTI_ARCH: ${{ needs.set-vars.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ needs.set-vars.outputs.MOD_VERSION }}
64 changes: 32 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# syntax=docker/dockerfile:1

## Buildstage ##
FROM ghcr.io/linuxserver/baseimage-alpine:3.17 as buildstage
FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage

ARG MOD_VERSION

RUN \
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" \
| awk '/tag_name/{print $4;exit}' FS='[""]' \
| sed 's|^v||'); \
Expand All @@ -18,45 +18,45 @@ RUN \
DOCKER_RELEASE=$(echo "${MOD_VERSION}" | sed 's|-.*||'); \
COMPOSE_RELEASE=$(echo "${MOD_VERSION}" | sed 's|.*-||'); \
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 ****" && \
SWITCH_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/compose-switch/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]' \
| 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 ****" && \
BUILDX_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/buildx/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]') && \
echo "**** grab buildx ****" && \
curl -fo \
/root-layer/docker-tgz/docker-buildx_x86_64 -L \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-amd64" && \
curl -fo \
/root-layer/docker-tgz/docker-buildx_aarch64 -L \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-arm64" && \
mkdir -p /root-layer/docker-tgz && \
if [ $(uname -m) = "x86_64" ]; then \
echo "**** grab x86_64 tarballs and binaries ****" && \
curl -fo \
/root-layer/docker-tgz/docker.tgz -L \
"https://download.docker.com/linux/static/stable/x86_64/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-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/* && \
rm -rf /tmp/*



# copy local files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ fi
if [ -d "/docker-tgz" ] ; then
echo "Copying over docker and docker-compose binaries"
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-buildx_${ARCH}" /usr/local/lib/docker/cli-plugins/docker-buildx
mv "/docker-tgz/compose-switch_${ARCH}" /usr/local/bin/docker-compose
tar xf /docker-tgz/docker_${ARCH}.tgz \
mv "/docker-tgz/docker-compose" /usr/local/lib/docker/cli-plugins/docker-compose
mv "/docker-tgz/docker-buildx" /usr/local/lib/docker/cli-plugins/docker-buildx
mv "/docker-tgz/compose-switch" /usr/local/bin/docker-compose
tar xf /docker-tgz/docker.tgz \
--strip-components=1 -C \
/usr/local/bin/
rm -rf /docker-tgz
Expand Down

0 comments on commit e202c69

Please sign in to comment.