Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ on:
env:
BUILD_TAG: nextcloud:test
CONTAINER_NAME: nextcloud
PUID: "1234"
PGID: "1235"

jobs:
test:
Expand Down Expand Up @@ -46,7 +48,7 @@ jobs:
-
name: Start
run: |
docker compose up -d
docker compose up -d --wait --wait-timeout 120
working-directory: test/${{ matrix.dir }}
env:
NEXTCLOUD_IMAGE: ${{ env.BUILD_TAG }}
Expand All @@ -57,6 +59,16 @@ jobs:
with:
name: ${{ env.CONTAINER_NAME }}
log_check: "ready to handle connections"
-
name: Check services
run: |
docker compose exec -T nextcloud sh -s < ../services.sh
docker compose exec -T cron sh -s < ../services.sh
docker compose exec -T previewgen sh -s < ../services.sh
working-directory: test/${{ matrix.dir }}
env:
NEXTCLOUD_IMAGE: ${{ env.BUILD_TAG }}
NEXTCLOUD_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Logs
if: always()
Expand Down
12 changes: 0 additions & 12 deletions rootfs/etc/cont-init.d/01-fix-uidgid.sh

This file was deleted.

Empty file.
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/config/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
8 changes: 8 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/config/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
with-contenv
if { /etc/s6-overlay/scripts/fix-logs }
if { /etc/s6-overlay/scripts/fix-uidgid }
if { /etc/s6-overlay/scripts/fix-perms }
if { /etc/s6-overlay/scripts/config }
if { /etc/s6-overlay/scripts/config-main }
if { /etc/s6-overlay/scripts/config-cron }
/etc/s6-overlay/scripts/config-previewgen
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/cron/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv sh

exec busybox crond -f -L /dev/stdout -c /var/spool/cron/crontabs
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/cron/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv sh

exec s6-setuidgid "${PUID}:${PGID}" nginx -g "daemon off;"
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/php-fpm/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv sh

exec s6-setuidgid "${PUID}:${PGID}" php-fpm -F
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/php-fpm/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
3 changes: 1 addition & 2 deletions rootfs/etc/cont-init.d/03-config.sh → rootfs/etc/s6-overlay/scripts/config
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
#!/bin/bash

runas_user() {
gosu nextcloud:nextcloud "$@"
Expand Down
17 changes: 4 additions & 13 deletions rootfs/etc/cont-init.d/05-svc-cron.sh → rootfs/etc/s6-overlay/scripts/config-cron
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/bin/sh

CRONTAB_PATH="/var/spool/cron/crontabs"
SIDECAR_CRON=${SIDECAR_CRON:-0}
Expand All @@ -15,7 +14,7 @@ echo ">>"

# Init
rm -rf ${CRONTAB_PATH}
mkdir -m 0644 -p ${CRONTAB_PATH}
mkdir -p ${CRONTAB_PATH}
touch ${CRONTAB_PATH}/nextcloud

# Cron
Expand All @@ -28,13 +27,5 @@ fi

# Fix perms
echo "Fixing crontabs permissions..."
chmod -R 0644 ${CRONTAB_PATH}

# Create service
mkdir -p /etc/services.d/cron
cat > /etc/services.d/cron/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
exec busybox crond -f -L /dev/stdout
EOL
chmod +x /etc/services.d/cron/run
chmod 0755 ${CRONTAB_PATH}
chmod 0644 ${CRONTAB_PATH}/nextcloud
21 changes: 1 addition & 20 deletions rootfs/etc/cont-init.d/04-svc-main.sh → rootfs/etc/s6-overlay/scripts/config-main
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/bin/sh

SIDECAR_CRON=${SIDECAR_CRON:-0}
SIDECAR_PREVIEWGEN=${SIDECAR_PREVIEWGEN:-0}
Expand Down Expand Up @@ -32,21 +31,3 @@ if [ -f /tmp/first-install ]; then
echo ">> Open your browser to configure your admin account"
echo ">>"
fi

mkdir -p /etc/services.d/nginx
cat > /etc/services.d/nginx/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
s6-setuidgid ${PUID}:${PGID}
nginx -g "daemon off;"
EOL
chmod +x /etc/services.d/nginx/run

mkdir -p /etc/services.d/php-fpm
cat > /etc/services.d/php-fpm/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
s6-setuidgid ${PUID}:${PGID}
php-fpm -F
EOL
chmod +x /etc/services.d/php-fpm/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/bin/sh

CRONTAB_PATH="/var/spool/cron/crontabs"
SIDECAR_PREVIEWGEN=${SIDECAR_PREVIEWGEN:-0}
Expand All @@ -15,7 +14,7 @@ echo ">>"

# Init
rm -rf ${CRONTAB_PATH}
mkdir -m 0644 -p ${CRONTAB_PATH}
mkdir -p ${CRONTAB_PATH}
touch ${CRONTAB_PATH}/nextcloud

# Cron
Expand All @@ -28,13 +27,5 @@ fi

# Fix perms
echo "Fixing crontabs permissions..."
chmod -R 0644 ${CRONTAB_PATH}

# Create service
mkdir -p /etc/services.d/cron
cat > /etc/services.d/cron/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
exec busybox crond -f -L /dev/stdout
EOL
chmod +x /etc/services.d/cron/run
chmod 0755 ${CRONTAB_PATH}
chmod 0644 ${CRONTAB_PATH}/nextcloud
3 changes: 1 addition & 2 deletions rootfs/etc/cont-init.d/00-fix-logs.sh → rootfs/etc/s6-overlay/scripts/fix-logs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/bin/sh

# Fix access rights to stdout and stderr
chown ${PUID}:${PGID} /proc/self/fd/1 /proc/self/fd/2 || true
3 changes: 1 addition & 2 deletions rootfs/etc/cont-init.d/02-fix-perms.sh → rootfs/etc/s6-overlay/scripts/fix-perms
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/with-contenv sh
# shellcheck shell=sh
#!/bin/sh

echo "Fixing perms..."
mkdir -p /data \
Expand Down
12 changes: 12 additions & 0 deletions rootfs/etc/s6-overlay/scripts/fix-uidgid
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

set -e

if [ -n "${PGID}" ] && [ "${PGID}" != "$(id -g nextcloud)" ]; then
echo "Switching to PGID ${PGID}..."
groupmod -o -g "${PGID}" nextcloud
fi
if [ -n "${PUID}" ] && [ "${PUID}" != "$(id -u nextcloud)" ]; then
echo "Switching to PUID ${PUID}..."
usermod -o -u "${PUID}" nextcloud
fi
13 changes: 13 additions & 0 deletions rootfs/etc/s6-overlay/scripts/runtime-bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/command/with-contenv sh
set -eu

contents=/etc/s6-overlay/s6-rc.d/user/contents.d
mkdir -p "${contents}"

if [ "${SIDECAR_CRON:-0}" = "1" ] || [ "${SIDECAR_PREVIEWGEN:-0}" = "1" ]; then
rm -f "${contents}/nginx" "${contents}/php-fpm"
touch "${contents}/cron"
else
rm -f "${contents}/cron"
touch "${contents}/nginx" "${contents}/php-fpm"
fi
25 changes: 25 additions & 0 deletions test/services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
set -eu

if [ "${SIDECAR_CRON:-0}" = "1" ] || [ "${SIDECAR_PREVIEWGEN:-0}" = "1" ]; then
services=cron
disabled="nginx php-fpm"
else
services="nginx php-fpm"
disabled=cron
fi

for service in $services; do
s6-svwait -u -t 30000 "/run/service/$service"
test "$(s6-svstat -o up,wantedup /run/service/"$service")" = "true true"
if [ "$service" != "cron" ]; then
pid=$(s6-svstat -o pid /run/service/"$service")
grep -Eq "^Uid:[[:space:]]+${PUID}[[:space:]]" "/proc/${pid}/status"
grep -Eq "^Gid:[[:space:]]+${PGID}[[:space:]]" "/proc/${pid}/status"
fi
done
for service in $disabled; do
test "$(s6-svstat -o up,wantedup /run/service/"$service")" = "false false"
done

/usr/local/bin/healthcheck
7 changes: 5 additions & 2 deletions v34.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG ALPINE_VERSION=3.24

FROM tianon/gosu:latest AS gosu

FROM --platform=${BUILDPLATFORM:-linux/amd64} crazymax/alpine-s6:${ALPINE_VERSION}-2.2.0.3 AS download
FROM --platform=${BUILDPLATFORM:-linux/amd64} alpine:${ALPINE_VERSION} AS download
RUN apk --update --no-cache add curl gnupg tar unzip xz
ARG NEXTCLOUD_VERSION
WORKDIR /tmp
Expand All @@ -17,7 +17,7 @@ RUN gpg --import "nextcloud.asc" \
WORKDIR /dist/nextcloud
RUN tar -xjf "/tmp/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2" --strip 1 -C .

FROM crazymax/alpine-s6:${ALPINE_VERSION}-2.2.0.3
FROM alpine:${ALPINE_VERSION}
RUN apk --update --no-cache add \
bash \
ca-certificates \
Expand Down Expand Up @@ -75,6 +75,8 @@ RUN apk --update --no-cache add \
php85-zip \
php85-zlib \
postgresql-client \
s6-overlay \
shadow \
tzdata \
util-linux \
&& mv /etc/php85 /etc/php && ln -s /etc/php /etc/php85 \
Expand All @@ -86,6 +88,7 @@ RUN apk --update --no-cache add \
&& rm -rf /tmp/* /var/www/*

ENV S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
S6_STAGE2_HOOK="/etc/s6-overlay/scripts/runtime-bundles" \
TZ="UTC" \
PUID="1000" \
PGID="1000"
Expand Down
7 changes: 5 additions & 2 deletions v35.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG ALPINE_VERSION=3.24

FROM tianon/gosu:latest AS gosu

FROM --platform=${BUILDPLATFORM:-linux/amd64} crazymax/alpine-s6:${ALPINE_VERSION}-2.2.0.3 AS download
FROM --platform=${BUILDPLATFORM:-linux/amd64} alpine:${ALPINE_VERSION} AS download
RUN apk --update --no-cache add curl gnupg tar unzip xz
ARG NEXTCLOUD_VERSION
WORKDIR /tmp
Expand All @@ -17,7 +17,7 @@ RUN gpg --import "nextcloud.asc" \
WORKDIR /dist/nextcloud
RUN tar -xjf "/tmp/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2" --strip 1 -C .

FROM crazymax/alpine-s6:${ALPINE_VERSION}-2.2.0.3
FROM alpine:${ALPINE_VERSION}
RUN apk --update --no-cache add \
bash \
ca-certificates \
Expand Down Expand Up @@ -75,6 +75,8 @@ RUN apk --update --no-cache add \
php85-zip \
php85-zlib \
postgresql-client \
s6-overlay \
shadow \
tzdata \
util-linux \
&& mv /etc/php85 /etc/php && ln -s /etc/php /etc/php85 \
Expand All @@ -86,6 +88,7 @@ RUN apk --update --no-cache add \
&& rm -rf /tmp/* /var/www/*

ENV S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
S6_STAGE2_HOOK="/etc/s6-overlay/scripts/runtime-bundles" \
TZ="UTC" \
PUID="1000" \
PGID="1000"
Expand Down
Loading