Merge pull request #742 from linuxserver/universal-docker-buildx

universal-docker: add buildx, deprecate armhf
This commit is contained in:
aptalca
2023-08-09 14:40:32 -04:00
committed by GitHub
3 changed files with 21 additions and 29 deletions
+11 -24
View File
@@ -5,10 +5,6 @@ FROM ghcr.io/linuxserver/baseimage-alpine:3.17 as buildstage
ARG MOD_VERSION
RUN \
echo "**** install packages ****" && \
apk add --no-cache \
git \
go && \
echo "**** retrieve latest version ****" && \
if [[ -z "${MOD_VERSION+x}" ]]; then \
DOCKER_RELEASE=$(curl -sX GET "https://api.github.com/repos/moby/moby/releases/latest" \
@@ -25,7 +21,6 @@ RUN \
mkdir -p \
/root-layer/docker-bins \
/tmp/docker_x86_64 \
/tmp/docker_armv7l \
/tmp/docker_aarch64 && \
curl -fo \
/tmp/docker_x86_64.tgz -L \
@@ -34,13 +29,6 @@ RUN \
/tmp/docker_x86_64.tgz -C \
/tmp/docker_x86_64 --strip-components=1 && \
cp /tmp/docker_x86_64/docker /root-layer/docker-bins/docker_x86_64 && \
curl -fo \
/tmp/docker_armv7l.tgz -L \
"https://download.docker.com/linux/static/stable/armhf/docker-${DOCKER_RELEASE}.tgz" && \
tar xf \
/tmp/docker_armv7l.tgz -C \
/tmp/docker_armv7l --strip-components=1 && \
cp /tmp/docker_armv7l/docker /root-layer/docker-bins/docker_armv7l && \
curl -fo \
/tmp/docker_aarch64.tgz -L \
"https://download.docker.com/linux/static/stable/aarch64/docker-${DOCKER_RELEASE}.tgz" && \
@@ -52,9 +40,6 @@ RUN \
curl -fo \
/root-layer/docker-bins/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-bins/docker-compose_armv7l -L \
"https://github.com/docker/compose/releases/download/v${COMPOSE_RELEASE}/docker-compose-linux-armv7" && \
curl -fo \
/root-layer/docker-bins/docker-compose_aarch64 -L \
"https://github.com/docker/compose/releases/download/v${COMPOSE_RELEASE}/docker-compose-linux-aarch64" && \
@@ -71,16 +56,18 @@ RUN \
curl -fo \
/root-layer/docker-bins/compose-switch_aarch64 -L \
"https://github.com/docker/compose-switch/releases/download/v${SWITCH_RELEASE}/docker-compose-linux-arm64" && \
echo "**** compile compose switch on armhf ****" && \
echo "**** retrieve latest buildx version ****" && \
if [ -z ${BUILDX_RELEASE+x} ]; then \
BUILDX_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/buildx/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
echo "**** grab buildx plugin ****" && \
curl -fo \
/tmp/compose-switch.tar.gz -L \
"https://github.com/docker/compose-switch/archive/refs/tags/v${SWITCH_RELEASE}.tar.gz" && \
mkdir -p /tmp/compose-switch && \
tar xf \
/tmp/compose-switch.tar.gz -C \
/tmp/compose-switch --strip-components=1 && \
cd /tmp/compose-switch && \
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w -X github.com/docker/compose-switch/internal.Version=${SWITCH_RELEASE}" -o /root-layer/docker-bins/compose-switch_armv7l ./main.go && \
/root-layer/docker-bins/docker-buildx_x86_64 -L \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-amd64" && \
curl -fo \
/root-layer/docker-bins/docker-buildx_aarch64 -L \
"https://github.com/docker/buildx/releases/download/${BUILDX_RELEASE}/buildx-${BUILDX_RELEASE}.linux-arm64" && \
chmod +x /root-layer/docker-bins/* && \
rm -rf /tmp/*
+1 -1
View File
@@ -1,6 +1,6 @@
# Docker - Docker mod for all images
This mod adds `docker` and `docker-compose` binaries to any linuxserver image.
This mod adds the `docker` binary as wells as the `buildx` and the `compose` plug-ins to any linuxserver image.
**IMPORTANT NOTE**: For docker access inside a container, a volume mapping needs to be added for `/var/run/docker.sock:/var/run/docker.sock:ro` in the container's docker run/create/compose. If you'd like to connect to a remote docker service instead, you don't have to map the docker sock; you can either set an env var for `DOCKER_HOST=remoteaddress` or use the docker cli option `-H`.
@@ -2,10 +2,15 @@
echo "**** installing docker and docker compose ****"
ARCH=$(uname -m)
if [ -d "/docker-bins" ] ; then
if [[ "${ARCH}" = "armv7l" ]]; then
echo "**** The universal docker mod no longer supports arm32v7/armhf per https://info.linuxserver.io/issues/2023-07-01-armhf/ ****"
exit 0
fi
if [[ -d "/docker-bins" ]] ; then
echo "Copying over docker and docker-compose binaries"
mkdir -p /usr/local/lib/docker/cli-plugins
mv "/docker-bins/docker-compose_${ARCH}" /usr/local/lib/docker/cli-plugins/docker-compose
mv "/docker-bins/docker-buildx_${ARCH}" /usr/local/lib/docker/cli-plugins/docker-buildx
mv "/docker-bins/docker_${ARCH}" /usr/local/bin/docker
mv "/docker-bins/compose-switch_${ARCH}" /usr/local/bin/docker-compose
rm -rf /docker-bins
@@ -13,19 +18,19 @@ else
echo "**** docker and docker-compose already installed, skipping ****"
fi
if [ -S /var/run/docker.sock ]; then
if [[ -S /var/run/docker.sock ]]; then
DOCKER_GID=$(stat -c '%g' "/var/run/docker.sock")
if id -G abc | grep -qw "$DOCKER_GID"; then
exit 0
else
DOCKER_NAME=$(getent group "${DOCKER_GID}" | awk -F: '{print $1}')
if [ -z "${DOCKER_NAME}" ]; then
if [[ -z "${DOCKER_NAME}" ]]; then
DOCKER_NAME="dockergroup"
groupadd -g "${DOCKER_GID}" "${DOCKER_NAME}"
fi
usermod -aG "${DOCKER_NAME}" abc
fi
elif [ -n "$DOCKER_HOST" ]; then
elif [[ -n "$DOCKER_HOST" ]]; then
echo "**** Remote docker service $DOCKER_HOST will be used ****"
else
echo "**** Please map /var/run/docker.sock for access to docker service on host. Alternatively you can manually define a remote host address with the docker cli option -H ****"