Skip to content

Commit

Permalink
Merge pull request #30 from theohbrothers/enhancement/install-docker-…
Browse files Browse the repository at this point in the history
…compose-v2.15.1-in-docker-and-docker-rootless-variants

Enhancement: Install `docker compose` `v2.15.1` in `docker` and `docker-rootless` variants
  • Loading branch information
leojonathanoh authored Jan 11, 2023
2 parents 790db9c + 53cd832 commit 3dc11a5
Show file tree
Hide file tree
Showing 9 changed files with 424 additions and 55 deletions.
79 changes: 64 additions & 15 deletions generate/templates/Dockerfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ RUN code-server --install-extension [email protected]
# Add a default settings.json
USER user
COPY --chown=1000:1000 settings.json /home/user/.local/share/code-server/User/settings.json
"@
}else {
# Incremental build
Expand All @@ -75,7 +77,7 @@ FROM $BASE_IMAGE
foreach ($c in $VARIANT['_metadata']['components']) {
if ($c -eq 'docker' -or $c -eq 'docker-rootless') {
$DOCKER_VERSION = '20.10.22'
@'
@"
# Install docker
# See: https://github.com/moby/moby/blob/v20.10.22/project/PACKAGERS.md
# Install docker-cli dependencies
Expand Down Expand Up @@ -105,9 +107,6 @@ RUN set -eux; \
adduser -S -G dockremap dockremap; \
echo 'dockremap:231072:65536' >> /etc/subuid; \
echo 'dockremap:231072:65536' >> /etc/subgid
'@
@"
# Install docker
RUN set -eux; \
case "`$( uname -m )" in \
Expand Down Expand Up @@ -144,17 +143,14 @@ RUN set -eux; \
docker --version; \
dockerd --version; \
runc --version
"@
@'
# Post-install docker. See: https://docs.docker.com/engine/install/linux-postinstall/
RUN set -eux; \
addgroup docker; \
adduser user docker;
VOLUME /var/lib/docker
'@
"@
if ($c -eq 'docker-rootless') {
@"
# Install rootless docker. See: https://docs.docker.com/engine/security/rootless/
Expand Down Expand Up @@ -205,24 +201,75 @@ ENV DOCKER_HOST=unix:///run/user/1000/docker.sock
"@
}
@"
# Install docker compose v2
USER root
RUN apk add --no-cache docker-cli-compose
# Install docker-compose v1 (deprecated, but for backward compatibility)
USER root
RUN apk add --no-cache docker-compose
"@

$DOCKER_COMPOSE_VERSION = 'v2.15.1'
$checksums = $global:CACHE['docker-compose-checksums'] = if (!$global:CACHE.Contains('docker-compose-checksums')) {
[System.Text.Encoding]::UTF8.GetString( (Invoke-WebRequest https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/checksums.txt).Content )
}else {
$global:CACHE['docker-compose-checksums']
}
@"
# Install docker compose v2. See: https://github.com/docker/compose/releases/
USER root
RUN set -eux; \
case "`$( uname -m )" in \
'x86_64') \
URL=https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/$( $checksums -split "`n" | ? { $_ -match 'linux-x86_64' } | % { $_ -split '\s' } | Select-Object -Last 1 | % { $_.TrimStart('*') } ); \
SHA256=$( $checksums -split "`n" | ? { $_ -match 'linux-x86_64' } | % { $_ -split '\s' } | Select-Object -First 1 ); \
;; \
'armhf') \
URL=https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/$( $checksums -split "`n" | ? { $_ -match 'linux-armv6' } | % { $_ -split '\s' } | Select-Object -Last 1 | % { $_.TrimStart('*') } ); \
SHA256=$( $checksums -split "`n" | ? { $_ -match 'linux-armv6' } | % { $_ -split '\s' } | Select-Object -First 1 ); \
;; \
'armv7') \
URL=https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/$( $checksums -split "`n" | ? { $_ -match 'linux-armv7' } | % { $_ -split '\s' } | Select-Object -Last 1 | % { $_.TrimStart('*') } ); \
SHA256=$( $checksums -split "`n" | ? { $_ -match 'linux-armv7' } | % { $_ -split '\s' } | Select-Object -First 1 ); \
;; \
'aarch64') \
URL=https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/$( $checksums -split "`n" | ? { $_ -match 'linux-aarch64' } | % { $_ -split '\s' } | Select-Object -Last 1 | % { $_.TrimStart('*') } ); \
SHA256=$( $checksums -split "`n" | ? { $_ -match 'linux-aarch64' } | % { $_ -split '\s' } | Select-Object -First 1 ); \
;; \
'ppc64le') \
URL=https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/$( $checksums -split "`n" | ? { $_ -match 'linux-ppc64le' } | % { $_ -split '\s' } | Select-Object -Last 1 | % { $_.TrimStart('*') } ); \
SHA256=$( $checksums -split "`n" | ? { $_ -match 'linux-ppc64le' } | % { $_ -split '\s' } | Select-Object -First 1 ); \
;; \
'riscv64') \
URL=https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/$( $checksums -split "`n" | ? { $_ -match 'linux-riscv64' } | % { $_ -split '\s' } | Select-Object -Last 1 | % { $_.TrimStart('*') } ); \
SHA256=$( $checksums -split "`n" | ? { $_ -match 'linux-riscv64' } | % { $_ -split '\s' } | Select-Object -First 1 ); \
;; \
's390x') \
URL=https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/$( $checksums -split "`n" | ? { $_ -match 'linux-s390x' } | % { $_ -split '\s' } | Select-Object -Last 1 | % { $_.TrimStart('*') } ); \
SHA256=$( $checksums -split "`n" | ? { $_ -match 'linux-s390x' } | % { $_ -split '\s' } | Select-Object -First 1 ); \
;; \
*) \
echo "Architecture not supported"; \
exit 1; \
;; \
esac; \
wget -qO- "`$URL" > docker-compose \
&& sha256sum docker-compose | grep "^`$SHA256 " \
&& mkdir -pv /usr/libexec/docker/cli-plugins \
&& mv -v docker-compose /usr/libexec/docker/cli-plugins/docker-compose \
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
&& docker compose version
"@

$DOCKER_BUILDX_VERSION = 'v0.9.1'
$checksums = $global:CACHE['docker-buildx-checksums'] = if (!$global:CACHE.Contains('docker-buildx-checksums')) {
[System.Text.Encoding]::UTF8.GetString( (Invoke-WebRequest https://github.com/docker/buildx/releases/download/$DOCKER_BUILDX_VERSION/checksums.txt).Content )
}else {
$global:CACHE['docker-buildx-checksums']
}
@"
# Install docker buildx plugin
# Install docker buildx plugin. See: https://github.com/docker/buildx
USER root
RUN set -eux; \
case "`$( uname -m )" in \
Expand Down Expand Up @@ -265,6 +312,8 @@ RUN set -eux; \
&& mv -v docker-buildx /usr/libexec/docker/cli-plugins/docker-buildx \
&& chmod +x /usr/libexec/docker/cli-plugins/docker-buildx \
&& docker buildx version
"@
}
if ($c -match 'pwsh-([^-]+)') {
Expand Down Expand Up @@ -309,14 +358,14 @@ RUN pwsh -c 'Install-Module Pester -Force -Scope AllUsers -MinimumVersion 4.0.0
# Install extensions
USER user
RUN code-server --install-extension [email protected]
"@
}
}
}

@"
# Remove the default code-server config file created when extensions are installed
USER user
RUN rm -fv ~/.config/code-server/config.yaml
Expand Down
50 changes: 45 additions & 5 deletions variants/v4.6.1-docker-alpine-3.15/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,55 @@ RUN set -eux; \
adduser user docker;
VOLUME /var/lib/docker

# Install docker compose v2
USER root
RUN apk add --no-cache docker-cli-compose

# Install docker-compose v1 (deprecated, but for backward compatibility)
USER root
RUN apk add --no-cache docker-compose

# Install docker buildx plugin
# Install docker compose v2. See: https://github.com/docker/compose/releases/
USER root
RUN set -eux; \
case "$( uname -m )" in \
'x86_64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64; \
SHA256=bcfd9ea51dee4c19dccdfaeef0e7956ef68bf14f3d175933742061a7271ef0f5; \
;; \
'armhf') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv6; \
SHA256=a8934600100af88f535eb50b45c7d8d2ac37835221803ba2910e0b167b3af22e; \
;; \
'armv7') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv7; \
SHA256=e5b03ac1258ad4243af0ac4afcb1c6cc8c9956b2483a50309cdb38cdb8387e37; \
;; \
'aarch64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-aarch64; \
SHA256=14d31297794868520cb2e61b543bb1c821aaa484af22b397904314ae8227f6a2; \
;; \
'ppc64le') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-ppc64le; \
SHA256=bdada874a26d382b20ced7c170707a1ebcf9f20d7d6f394b962076968473ca9c; \
;; \
'riscv64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-riscv64; \
SHA256=9cc1b9c8de313a1e43b8f3dcca47c29eeb87af3de24c67448c463bf882166430; \
;; \
's390x') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-s390x; \
SHA256=cf311824af115d0bece5d5d60a73464912dad07cdd00fdaa469dabbcad60f289; \
;; \
*) \
echo "Architecture not supported"; \
exit 1; \
;; \
esac; \
wget -qO- "$URL" > docker-compose \
&& sha256sum docker-compose | grep "^$SHA256 " \
&& mkdir -pv /usr/libexec/docker/cli-plugins \
&& mv -v docker-compose /usr/libexec/docker/cli-plugins/docker-compose \
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
&& docker compose version

# Install docker buildx plugin. See: https://github.com/docker/buildx
USER root
RUN set -eux; \
case "$( uname -m )" in \
Expand Down
50 changes: 45 additions & 5 deletions variants/v4.6.1-docker-rootless-alpine-3.15/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,55 @@ VOLUME /home/user/.local/share/docker
ENV XDG_RUNTIME_DIR=/run/user/1000
ENV DOCKER_HOST=unix:///run/user/1000/docker.sock

# Install docker compose v2
USER root
RUN apk add --no-cache docker-cli-compose

# Install docker-compose v1 (deprecated, but for backward compatibility)
USER root
RUN apk add --no-cache docker-compose

# Install docker buildx plugin
# Install docker compose v2. See: https://github.com/docker/compose/releases/
USER root
RUN set -eux; \
case "$( uname -m )" in \
'x86_64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64; \
SHA256=bcfd9ea51dee4c19dccdfaeef0e7956ef68bf14f3d175933742061a7271ef0f5; \
;; \
'armhf') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv6; \
SHA256=a8934600100af88f535eb50b45c7d8d2ac37835221803ba2910e0b167b3af22e; \
;; \
'armv7') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv7; \
SHA256=e5b03ac1258ad4243af0ac4afcb1c6cc8c9956b2483a50309cdb38cdb8387e37; \
;; \
'aarch64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-aarch64; \
SHA256=14d31297794868520cb2e61b543bb1c821aaa484af22b397904314ae8227f6a2; \
;; \
'ppc64le') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-ppc64le; \
SHA256=bdada874a26d382b20ced7c170707a1ebcf9f20d7d6f394b962076968473ca9c; \
;; \
'riscv64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-riscv64; \
SHA256=9cc1b9c8de313a1e43b8f3dcca47c29eeb87af3de24c67448c463bf882166430; \
;; \
's390x') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-s390x; \
SHA256=cf311824af115d0bece5d5d60a73464912dad07cdd00fdaa469dabbcad60f289; \
;; \
*) \
echo "Architecture not supported"; \
exit 1; \
;; \
esac; \
wget -qO- "$URL" > docker-compose \
&& sha256sum docker-compose | grep "^$SHA256 " \
&& mkdir -pv /usr/libexec/docker/cli-plugins \
&& mv -v docker-compose /usr/libexec/docker/cli-plugins/docker-compose \
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
&& docker compose version

# Install docker buildx plugin. See: https://github.com/docker/buildx
USER root
RUN set -eux; \
case "$( uname -m )" in \
Expand Down
50 changes: 45 additions & 5 deletions variants/v4.7.1-docker-alpine-3.15/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,55 @@ RUN set -eux; \
adduser user docker;
VOLUME /var/lib/docker

# Install docker compose v2
USER root
RUN apk add --no-cache docker-cli-compose

# Install docker-compose v1 (deprecated, but for backward compatibility)
USER root
RUN apk add --no-cache docker-compose

# Install docker buildx plugin
# Install docker compose v2. See: https://github.com/docker/compose/releases/
USER root
RUN set -eux; \
case "$( uname -m )" in \
'x86_64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64; \
SHA256=bcfd9ea51dee4c19dccdfaeef0e7956ef68bf14f3d175933742061a7271ef0f5; \
;; \
'armhf') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv6; \
SHA256=a8934600100af88f535eb50b45c7d8d2ac37835221803ba2910e0b167b3af22e; \
;; \
'armv7') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv7; \
SHA256=e5b03ac1258ad4243af0ac4afcb1c6cc8c9956b2483a50309cdb38cdb8387e37; \
;; \
'aarch64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-aarch64; \
SHA256=14d31297794868520cb2e61b543bb1c821aaa484af22b397904314ae8227f6a2; \
;; \
'ppc64le') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-ppc64le; \
SHA256=bdada874a26d382b20ced7c170707a1ebcf9f20d7d6f394b962076968473ca9c; \
;; \
'riscv64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-riscv64; \
SHA256=9cc1b9c8de313a1e43b8f3dcca47c29eeb87af3de24c67448c463bf882166430; \
;; \
's390x') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-s390x; \
SHA256=cf311824af115d0bece5d5d60a73464912dad07cdd00fdaa469dabbcad60f289; \
;; \
*) \
echo "Architecture not supported"; \
exit 1; \
;; \
esac; \
wget -qO- "$URL" > docker-compose \
&& sha256sum docker-compose | grep "^$SHA256 " \
&& mkdir -pv /usr/libexec/docker/cli-plugins \
&& mv -v docker-compose /usr/libexec/docker/cli-plugins/docker-compose \
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
&& docker compose version

# Install docker buildx plugin. See: https://github.com/docker/buildx
USER root
RUN set -eux; \
case "$( uname -m )" in \
Expand Down
50 changes: 45 additions & 5 deletions variants/v4.7.1-docker-rootless-alpine-3.15/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,55 @@ VOLUME /home/user/.local/share/docker
ENV XDG_RUNTIME_DIR=/run/user/1000
ENV DOCKER_HOST=unix:///run/user/1000/docker.sock

# Install docker compose v2
USER root
RUN apk add --no-cache docker-cli-compose

# Install docker-compose v1 (deprecated, but for backward compatibility)
USER root
RUN apk add --no-cache docker-compose

# Install docker buildx plugin
# Install docker compose v2. See: https://github.com/docker/compose/releases/
USER root
RUN set -eux; \
case "$( uname -m )" in \
'x86_64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64; \
SHA256=bcfd9ea51dee4c19dccdfaeef0e7956ef68bf14f3d175933742061a7271ef0f5; \
;; \
'armhf') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv6; \
SHA256=a8934600100af88f535eb50b45c7d8d2ac37835221803ba2910e0b167b3af22e; \
;; \
'armv7') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-armv7; \
SHA256=e5b03ac1258ad4243af0ac4afcb1c6cc8c9956b2483a50309cdb38cdb8387e37; \
;; \
'aarch64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-aarch64; \
SHA256=14d31297794868520cb2e61b543bb1c821aaa484af22b397904314ae8227f6a2; \
;; \
'ppc64le') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-ppc64le; \
SHA256=bdada874a26d382b20ced7c170707a1ebcf9f20d7d6f394b962076968473ca9c; \
;; \
'riscv64') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-riscv64; \
SHA256=9cc1b9c8de313a1e43b8f3dcca47c29eeb87af3de24c67448c463bf882166430; \
;; \
's390x') \
URL=https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-s390x; \
SHA256=cf311824af115d0bece5d5d60a73464912dad07cdd00fdaa469dabbcad60f289; \
;; \
*) \
echo "Architecture not supported"; \
exit 1; \
;; \
esac; \
wget -qO- "$URL" > docker-compose \
&& sha256sum docker-compose | grep "^$SHA256 " \
&& mkdir -pv /usr/libexec/docker/cli-plugins \
&& mv -v docker-compose /usr/libexec/docker/cli-plugins/docker-compose \
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
&& docker compose version

# Install docker buildx plugin. See: https://github.com/docker/buildx
USER root
RUN set -eux; \
case "$( uname -m )" in \
Expand Down
Loading

0 comments on commit 3dc11a5

Please sign in to comment.