Skip to content

Commit 2f381e5

Browse files
committed
universal-docker: initial release
1 parent ca3be57 commit 2f381e5

File tree

7 files changed

+86
-76
lines changed

7 files changed

+86
-76
lines changed

.travis.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ language: shell
44

55
branches:
66
only:
7-
- <baseimagename>-<modname> #replace variables, omit brackets
7+
- universal-docker
88

99
services:
1010
- docker
1111

1212
env:
1313
global:
14-
- DOCKERHUB="linuxserver/mods" #don't modify
15-
- BASEIMAGE="baseimagename" #replace
16-
- MODNAME="modname" #replace
14+
- DOCKERHUB="linuxserver/mods"
15+
- BASEIMAGE="universal"
16+
- MODNAME="docker"
1717

1818
jobs:
1919
include:
@@ -25,11 +25,19 @@ jobs:
2525
- stage: BuildImage
2626
if: (NOT (type IN (pull_request)))
2727
script:
28+
# Set version
29+
- if [ -z ${COMPOSE_TAG+x} ]; then COMPOSE_TAG=$(curl -sX GET "https://api.github.com/repos/linuxserver/docker-docker-compose/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]'); fi
30+
- if [ -z ${COMPOSE_ALPINE_TAG+x} ]; then COMPOSE_ALPINE_TAG=$(curl -sX GET "https://api.github.com/repos/linuxserver/docker-docker-compose/releases" | jq -r 'first(.[] | select(.prerelease==true)) | .tag_name'); fi
31+
- COMPOSE_VERSION=$(echo "$COMPOSE_TAG" | sed 's|-ls.*||g')
32+
- COMPOSE_ALPINE_VERSION="$(echo ${COMPOSE_ALPINE_TAG} | sed 's|-ls.*||g' | sed 's|alpine-||g')"
33+
- if [ "$COMPOSE_VERSION" != "$COMPOSE_ALPINE_VERSION" ]; then echo "ubuntu and alpine versions are different; exiting!" && travis_terminate 1; else echo "ubuntu and alpine versions are the same, continuing with build"; fi
2834
# Build image
29-
- docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
30-
- docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
35+
- docker build --no-cache --build-arg COMPOSE_TAG=${COMPOSE_TAG} --build-arg COMPOSE_ALPINE_TAG=${COMPOSE_ALPINE_TAG} -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${COMPOSE_VERSION}-${TRAVIS_COMMIT} .
36+
- docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${COMPOSE_VERSION}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${COMPOSE_VERSION}
37+
- docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${COMPOSE_VERSION}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
3138
# Login to DockerHub
3239
- echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin
3340
# Push all of the tags
34-
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT}
41+
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${COMPOSE_VERSION}-${TRAVIS_COMMIT}
42+
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${COMPOSE_VERSION}
3543
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}

Dockerfile

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
1+
ARG COMPOSE_TAG="latest"
2+
ARG COMPOSE_ALPINE_TAG="alpine"
3+
4+
FROM linuxserver/docker-compose:amd64-${COMPOSE_TAG} as compose-amd64
5+
FROM linuxserver/docker-compose:arm32v7-${COMPOSE_TAG} as compose-arm32
6+
FROM linuxserver/docker-compose:arm64v8-${COMPOSE_TAG} as compose-arm64
7+
FROM linuxserver/docker-compose:amd64-${COMPOSE_ALPINE_TAG} as compose-alpine-amd64
8+
FROM linuxserver/docker-compose:arm32v7-${COMPOSE_ALPINE_TAG} as compose-alpine-arm32
9+
FROM linuxserver/docker-compose:arm64v8-${COMPOSE_ALPINE_TAG} as compose-alpine-arm64
10+
11+
FROM lsiobase/alpine:3.12 as buildstage
12+
13+
COPY --from=compose-amd64 /usr/local/bin/docker-compose /root-layer/docker-compose-ubuntu/docker-compose_x86_64
14+
COPY --from=compose-amd64 /usr/local/bin/docker /root-layer/docker-compose-ubuntu/docker_x86_64
15+
COPY --from=compose-arm32 /usr/local/bin/docker-compose /root-layer/docker-compose-ubuntu/docker-compose_armv7l
16+
COPY --from=compose-arm32 /usr/local/bin/docker /root-layer/docker-compose-ubuntu/docker_armv7l
17+
COPY --from=compose-arm64 /usr/local/bin/docker-compose /root-layer/docker-compose-ubuntu/docker-compose_aarch64
18+
COPY --from=compose-arm64 /usr/local/bin/docker /root-layer/docker-compose-ubuntu/docker_aarch64
19+
COPY --from=compose-alpine-amd64 /usr/local/bin/docker-compose /root-layer/docker-compose-alpine/docker-compose_x86_64
20+
COPY --from=compose-alpine-amd64 /usr/local/bin/docker /root-layer/docker-compose-alpine/docker_x86_64
21+
COPY --from=compose-alpine-arm32 /usr/local/bin/docker-compose /root-layer/docker-compose-alpine/docker-compose_armv7l
22+
COPY --from=compose-alpine-arm32 /usr/local/bin/docker /root-layer/docker-compose-alpine/docker_armv7l
23+
COPY --from=compose-alpine-arm64 /usr/local/bin/docker-compose /root-layer/docker-compose-alpine/docker-compose_aarch64
24+
COPY --from=compose-alpine-arm64 /usr/local/bin/docker /root-layer/docker-compose-alpine/docker_aarch64
25+
COPY root/ /root-layer/
26+
27+
# runtime stage
128
FROM scratch
229

3-
LABEL maintainer="username"
30+
LABEL maintainer="aptalca"
431

5-
# copy local files
6-
COPY root/ /
32+
# Add files from buildstage
33+
COPY --from=buildstage /root-layer/ /

Dockerfile.complex

Lines changed: 0 additions & 23 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
# Rsync - Docker mod for openssh-server
1+
# Docker - Docker mod for all images
22

3-
This mod adds rsync to openssh-server, to be installed/updated during container start.
3+
This mod adds `docker` and `docker-compose` binaries to any linuxserver image.
44

5-
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
5+
**IMPORTANT NOTE**: For docker access inside a container, a volume mapping needs to be added for `/var/run/docker.sock:/var/run/docker.sock` 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`.
66

7-
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
7+
In the container's docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:universal-docker` to enable.
88

9-
# Mod creation instructions
10-
11-
* Fork the repo, create a new branch based on the branch `template`.
12-
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
13-
* Inspect the `root` folder contents. Edit, add and remove as necessary.
14-
* Edit this readme with pertinent info, delete these instructions.
15-
* Finally edit the `travis.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
16-
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
17-
* Submit PR against the branch created by the team.
9+
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:universal-mod2`

root/etc/cont-init.d/95-docker

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
echo "**** installing docker and docker compose ****"
4+
if [ -f /usr/bin/apt ]; then
5+
DISTRONAME="ubuntu"
6+
else
7+
DISTRONAME="alpine"
8+
fi
9+
ARCH=$(uname -m)
10+
if [ -f "/docker-compose-${DISTRONAME}/docker-compose_${ARCH}" ] ; then
11+
echo "Copying over docker and docker-compose binaries"
12+
mv "/docker-compose-${DISTRONAME}/docker-compose_${ARCH}" /usr/local/bin/docker-compose
13+
mv "/docker-compose-${DISTRONAME}/docker_${ARCH}" /usr/local/bin/docker
14+
chmod +x /usr/local/bin/docker-compose
15+
rm -rf /docker-compose-ubuntu /docker-compose-alpine
16+
else
17+
echo "**** docker and docker-compose already installed, skipping ****"
18+
fi
19+
20+
if [ -S /var/run/docker.sock ]; then
21+
DOCKER_GID=$(stat -c '%g' "/var/run/docker.sock")
22+
if id -G abc | grep -qw "$DOCKER_GID"; then
23+
exit 0
24+
else
25+
DOCKER_NAME=$(getent group "${DOCKER_GID}" | awk -F: '{print $1}')
26+
if [ -z "${DOCKER_NAME}" ]; then
27+
DOCKER_NAME="dockergroup"
28+
groupadd -g "${DOCKER_GID}" "${DOCKER_NAME}"
29+
fi
30+
usermod -aG "${DOCKER_NAME}" abc
31+
fi
32+
elif [ -n "$DOCKER_HOST" ]; then
33+
echo "**** /var/run/docker.sock is not mapped, therefore, docker client will only work with a remote docker service ****"
34+
else
35+
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 ****"
36+
fi

root/etc/cont-init.d/98-vpn-config

Lines changed: 0 additions & 27 deletions
This file was deleted.

root/etc/services.d/sshvpn/run

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)