run docker dev nextcloud

- missing clone info
- missing setup of certificates (mkcert and so one ... )
This commit is contained in:
2025-09-29 16:05:00 +02:00
parent ad09c3ec72
commit 6a2ccb5d2b
4 changed files with 379 additions and 33 deletions

View File

@@ -63,3 +63,33 @@ utiliser la base de donnee postgres et non le SQLLite ?
./migrate_db_sqlite2postgres.sh ./migrate_db_sqlite2postgres.sh
# NEW PLAIN nextcloud dev
setup
```
git clone git@github.com:juliusknorr/nextcloud-docker-dev.git
git git@github.com:nextcloud/server.git
```
check nextcloud-docker-dev.env then
```
cp nextcloud-docker-dev.env nextcloud-docker-dev.git/.env
```
https setup, local private PKI.
missing setup cert and setupcert host ... mkcert compilation + install
update-certs update-hosts
https://nextcloud-dev.l0g.eu
then will be done as sudo ( RootLess or podman limitation ? )
```
./runit.sh
```

View File

@@ -1,30 +1,72 @@
#!/bin/bash #!/bin/bash
# SPDX-FileCopyrightText: 2025 artlog@l0g.eu
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# metascript to include # metascript to include
# #
# usual way if no parameters used by outer script : # to generate file header for caller script do :
# # bash <relative_path_to>/metascript.sh header
# source $(dirname "$0")/metascript.sh # ex:
# # bash lib/metascript.sh header
# defaultmetainit $@
# if called directly
if [[ "$0" =~ ^(.*)/metascript.sh$ ]]
then
prefix=${BASH_REMATCH[1]}
if [[ $1 == header ]]
then
cat <<EOF
#!/bin/bash
# SPDX-FileCopyrightText: 2025 artlog@l0g.eu
# SPDX-License-Identifier: AGPL-3.0-or-later
# #
# sample to include this script.
toolsdir=$prefix
pushd \$toolsdir >/dev/null
toolsdir=\$(pwd)
source metascript.sh
popd >/dev/null
while [[ \$# > 0 ]]
do
case "\$1" in
*)
parsemetaarg "\$1"
;;
esac
shift
done
exit 0
EOF
else
echo "[WARNING] only header argument is supported. (prefix=$prefix)" >&2
fi
exit 0
fi
if [[ "$metascript_included" == "yes" ]]
then
log_warn "metascript already included ($0)"
else
metascript_included=yes metascript_included=yes
# assume all tools are in lib/ # at this step $(pwd) should be this of metascript.sh
toolsdir=$(dirname $(readlink -f $0))/lib # while $0 is this of caller script using metascript
# all tools resources are relative to this directory
# project directory if [[ -z $toolsdir ]]
# relative then
# toolsparentdir=$(realpath --relative-to "$(pwd)" $(readlink -f $0))/ # assume all tools are in lib/
# absolute toolsdir=$(dirname $(readlink -f $0))/lib
toolsparentdir=$(realpath $(readlink -f $0))/ # all tools resources are relative to this directory
fi
if [[ -z $log_functions ]] if [[ -z $log_functions ]]
then then
log_functions=$toolsdir/log_functions.sh log_functions=$toolsdir/log_functions.sh
[[ -f $log_functions ]] || { echo "[FATAL] Missing $log_functions" >&2 ; exit 1 ;} [[ -f $log_functions ]] || { echo "[FATAL] Missing $log_functions , toolsdir=$toolsdir script=$0" >&2 ; exit 1 ;}
source $log_functions source $log_functions
fi fi
@@ -36,7 +78,7 @@ metascript commands :
help|usage help or usage of this {$0} tool help|usage help or usage of this {$0} tool
dryrun|show|showdoc display what should/will be done dryrun|show|showdoc display what should/will be done
defersource= script file defining defer() non sandard function defersource= script file defining defer() non standard function
defer= defer function to use, default is showdoc defer= defer function to use, default is showdoc
toolsresourcesdir= where to pick resource toolsresourcesdir= where to pick resource
default to parent of script $toolsresourcesdir default to parent of script $toolsresourcesdir
@@ -54,7 +96,12 @@ usage()
showinfo() showinfo()
{ {
echo $@ echo "$@"
}
metarun()
{
$defer $metasudo "$@"
} }
showdoc() showdoc()
@@ -62,10 +109,10 @@ showdoc()
if [[ $1 =~ ^tools/ ]] if [[ $1 =~ ^tools/ ]]
then then
# assumes it handles ENV_METASCRIPT_DEFER # assumes it handles ENV_METASCRIPT_DEFER
$@ "$@"
else else
echo '```' echo '```'
autoquoteargs $@ autoquoteargs "$@"
echo echo
echo '```' echo '```'
fi fi
@@ -92,11 +139,11 @@ execredirectfrom()
if [[ -n $defer ]] if [[ -n $defer ]]
then then
echo '```' echo '```'
autoquoteargs $@ autoquoteargs "$@"
echo ' < '"$tofile" echo ' < '"$tofile"
echo '```' echo '```'
else else
$@ < $tofile "$@" < $tofile
fi fi
} }
@@ -107,7 +154,7 @@ execredirectto()
if [[ -n $defer ]] if [[ -n $defer ]]
then then
echo '```' echo '```'
autoquoteargs $@ autoquoteargs "$@"
echo ' > '"$tofile" echo ' > '"$tofile"
echo '```' echo '```'
else else
@@ -115,19 +162,34 @@ execredirectto()
fi fi
} }
execredirecttoroot()
{
tofile=$1
shift
if [[ -n $defer ]]
then
echo '```'
autoquoteargs "$@"
echo ' | sudo tee '"$tofile"
echo '```'
else
"$@" | sudo tee $tofile
fi
}
pipeto() pipeto()
{ {
if [[ -n $defer ]] if [[ -n $defer ]]
then then
echo '```' echo '```'
echo -n 'cat << EOF| ' echo -n 'cat << EOF| '
autoquoteargs $@ autoquoteargs "$@"
echo echo
cat cat
echo "EOF" echo "EOF"
echo '```' echo '```'
else else
cat | $@ cat | "$@"
fi fi
} }
@@ -355,6 +417,9 @@ parsemetaarg()
dryrun|show|showdoc) dryrun|show|showdoc)
defer=showdoc defer=showdoc
;; ;;
metasudo=*)
metasudo=${1/metasudo=}
;;
help|usage) help|usage)
usage usage
;; ;;
@@ -528,7 +593,7 @@ check_variable_in()
shift 2 shift 2
local value="" local value=""
local values=$@ local values="$@"
eval value='$'"$var" eval value='$'"$var"
@@ -570,17 +635,148 @@ get_timestamp_second()
echo "$(date +"%Y%m%d%H%M%S")" echo "$(date +"%Y%m%d%H%M%S")"
} }
if [[ -z $ENV_METASCRIPT_RESOURCESDIR ]] todo()
{
log_any TODO "$@"
}
get_resource_var() {
local varname="$1"
local default_value="$2"
eval value='$'"$varname"
if [[ -z $value ]]
then
echo "# ($0:metascript.sh:$LINENO) $(date)" >>$collect_context
if [[ -z $default_value ]]
then
log_error "resource $varname does not exists and no non empty default provided"
echo "# $varname=<MISSING>" >>$collect_context
exit 1
fi
log_warn "($0) Using default value '$varname'='$default_value' HARDCODED in script : should be fixed with proper default file .resources.var, see traces in $collect_context"
read "$varname" <<<"$default_value"
echo "$varname=$default_value" >>$collect_context
fi
}
setup_resources_var()
{
local resource_var="$1"
enforcefile "$resource_var" exists
while read line
do
if [[ $line =~ ^([a-zA-Z0-9_]+)=(.+)$ ]]
then
varname=${BASH_REMATCH[1]}
value=${BASH_REMATCH[2]}
read "$varname" <<<"$value"
elif [[ $line =~ ^# ]]
then
echo "$line"
else
log_warn "Invalid syntax in $resource_var '$line' does not match any expected expression"
fi
done <"$resource_var"
}
# allow to check mounted points
mountpoint_get_device()
{
local mount_point="$1"
$defer awk "{ if (\$2 == \""$mount_point"\") print \$1 ;}" /proc/mounts
}
device_get_mountpoints()
{
local device="$1"
$defer awk "{ if (\$1 == \""$device"\") print \$2 ;}" /proc/mounts
}
mount_if_needed()
{
local mountpoint="$1"
local mountdevice="$2"
local param="$3"
device=$(mountpoint_get_device "$mountpoint")
enforcedir "$mountpoint" exists
# device is a device ...
# enforcefile "$mountdevice" exists
if [[ -z $device ]]
then
$metarun mount $param "$mountdevice" "$device"
elif [[ "$device" == "$mountdevice" ]]
then
log_info "$device already mounted on $mountdevice"
else
log_warn "Another device $device is mounted on $mountdevice, not $mountdevice"
fi
}
umount_if_needed()
{
local mountpoint="$1"
local mountdevice="$2"
device=$(mountpoint_get_device "$mountpoint")
if [[ -n "$device" ]]
then
if [[ "$device" == "$mountpoint" ]]
then
$metarun umount "$mountpoint"
else
log_warn "Another device $device is mounted on $mountdevice, not $mountdevice"
fi
fi
}
# collect all hardcoded values.
mkdir -p ~/.artlog
collect_context=~/.artlog/collect_context.var
if [[ -z $toolsresourcesdir ]]
then then
toolsresourcesdir=$toolsparentdir # project directory
else
toolsresourcesdir=$ENV_METASCRIPT_RESOURCESDIR # from current $(pwd) will follow parent dir hierarchy to find .resources.var
dir="$(pwd)"
while [[ -n $dir ]] && [[ -d $dir ]] && [[ ! -f $dir/.resources.var ]]
do
new_dir=$(dirname "$dir")
if [[ $new_dir == $dir ]]
then
# protect against infinite loop
break
fi
dir="$new_dir"
done
if [[ -f $dir/.resources.var ]]
then
toolsresourcesdir=$dir
else
if [[ -z $ENV_METASCRIPT_RESOURCESDIR ]]
then
toolsresourcesdir=$toolsparentdir
else
toolsresourcesdir=$ENV_METASCRIPT_RESOURCESDIR
fi
fi
fi fi
# quick way to give scl patches to fill scl_arg array resources_var=$toolsresourcesdir/.resources.var
if [[ -f $toolsparentdir/.scl_env ]] if [[ -f $resources_var ]]
then then
source $toolsparentdir/.scl_env setup_resources_var "$resources_var"
else
log_warn "No $resources_var found"
fi
# quick way to give scl patches to fill scl_arg array
if [[ -f $toolsresourcesdir/.scl_env ]]
then
source $toolsresourcesdir/.scl_env
fi fi
# empty defer means doit # empty defer means doit
@@ -588,6 +784,11 @@ defer=$ENV_METASCRIPT_DEFER
showinfo=showinfo showinfo=showinfo
allparms=$@ allparms="$@"
applymetaargs=applymetaargs applymetaargs=applymetaargs
metarun=$defer
# metascript included
fi

View File

@@ -0,0 +1,72 @@
COMPOSE_PROJECT_NAME=master
# Default protocol to use for Nextcloud and other containers
# check the readme for details how to setup https
PROTOCOL=https
# Paths
REPO_PATH_SERVER=/home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/nextcloud_devenv/server
# Specify a path to apps which will be shared between all containers. Useful for apps that support multiple nextcloud versions
# ADDITIONAL_APPS_PATH=/home/alice/nextcloud-docker-dev/workspace/server/apps-shared
# Stable releases root directory
# STABLE_ROOT_PATH=/home/alice/nextcloud-docker-dev/workspace
# Install Nextcloud apps per default
# NEXTCLOUD_AUTOINSTALL_APPS="viewer activity"
# Retry enabling apps for a provided amount of time (can be useful when using the containers in CI)
# NEXTCLOUD_AUTOINSTALL_APPS_WAIT_TIME=0
# Blackfire configuration
# BLACKFIRE_CLIENT_ID=
# BLACKFIRE_CLIENT_TOKEN=
# BLACKFIRE_SERVER_ID=
# BLACKFIRE_SERVER_TOKEN=
# By default the published ports are only accessible at 127.0.0.1 (your localhost).
# Set this to '0.0.0.0' to make them accessible from your whole local network.
# IP_BIND=127.0.0.1
# can be used to run separate setups besides each other
# DOCKER_SUBNET=192.168.15.0/24
# PORTBASE=815
# Main dns names for ssl proxy
# This can be used to append a custom domain name to the container names
DOMAIN_SUFFIX=-dev.l0g.eu
# May be used to set the PHP version. Defaults to 7.2.
# PHP_VERSION=71
# PHP_VERSION=72
# PHP_VERSION=73
# PHP_VERSION=74
# PHP_VERSION=80
PHP_VERSION=81
# May be used to choose database (sqlite, pgsql, mysql)
SQL=mysql
# The mode of the xdebuger extention. This can be a comma separated list of
# the entries none, develop, debug, trace, and profile.
PHP_XDEBUG_MODE=develop
# Docker socket location, use it when you run rootless Docker
# Replace "1000" with the uid used by your Docker engine (default $(id -u))
# DOCKER_SOCKET=/run/user/1000/docker.sock
DOCKER_SOCKET=/var/run/podman/podman.sock
# Nextcloud AppAPI Docker Socket Proxy
# ------------------------------------
# NC_HAPROXY_PASSWORD=some_secure_password
# BIND_ADDRESS=172.17.0.1
# CERT_PATH=./data/ssl/app_api/app_api.pem
# NETWORK_MODE=host
# HAPROXY_PORT=2375
# TIMEOUT_CONNECT=10s
# TIMEOUT_CLIENT=30s
# TIMEOUT_SERVER=30s
# EX_APPS_NET=ipv4@localhost
# EX_APPS_COUNT=50
# ------------------------------------

43
nextcloud_devenv/runit.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2025 artlog@l0g.eu
# SPDX-License-Identifier: AGPL-3.0-or-later
#
toolsdir=lib
pushd $toolsdir >/dev/null
toolsdir=$(pwd)
source metascript.sh
popd >/dev/null
while [[ $# > 0 ]]
do
case "$1" in
up|down)
action=$1
;;
*)
parsemetaarg "$1"
;;
esac
shift
done
metarun=metarun
metasudo=sudo
enforcedir nextcloud-docker-dev exists
pushd nextcloud-docker-dev
if [[ $action = down ]]
then
$metarun podman-compose down
fi
services=(nextcloud proxy database-mysql)
if [[ $action == up ]]
then
$metarun podman-compose --env-file $(pwd)/.env $action "${services[@]}"
fi
popd