mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-11-28 08:52:00 +02:00
[Compose] Update to Docker Compose v2 (#4605)
* Change default HTTP_BIND, HTTPS_BIND
https://github.com/mailcow/mailcow-dockerized/issues/4315#issuecomment-1083034329
* [Compose] Removed Colon after fallback IP in docker-compose.yml
* [Compose] Remove bind options from volumes (#4577)
(cherry picked from commit 4d53216c05
)
* Migration (partially) of update.sh + cold-standby.sh to composev2
* Migration of update.sh + cold-standby.sh to composev2
* Migration of update.sh + cold-standby.sh to composev2
* Migration of update.sh + cold-standby.sh to composev2
* [ClamAV] Fixed ClamAV start before unbound
* Migration of update.sh + cold-standby.sh to composev2
* Formulation and values adjusted (IPv4 bind in generate-config.sh)
Co-authored-by: Amin Vakil <info@aminvakil.com>
Co-authored-by: qupfer <github@qupfer.de>
Co-authored-by: FreddleSpl0it <patschul@posteo.de>
This commit is contained in:
parent
c9700773f4
commit
714511b0a8
@ -60,6 +60,8 @@ services:
|
||||
clamd-mailcow:
|
||||
image: mailcow/clamd:1.52
|
||||
restart: always
|
||||
depends_on:
|
||||
- unbound-mailcow
|
||||
dns:
|
||||
- ${IPV4_NETWORK:-172.22.1}.254
|
||||
environment:
|
||||
@ -375,8 +377,8 @@ services:
|
||||
- ./data/conf/rspamd/meta_exporter:/meta_exporter:ro,z
|
||||
- sogo-web-vol-1:/usr/lib/GNUstep/SOGo/
|
||||
ports:
|
||||
- "${HTTPS_BIND:-:}:${HTTPS_PORT:-443}:${HTTPS_PORT:-443}"
|
||||
- "${HTTP_BIND:-:}:${HTTP_PORT:-80}:${HTTP_PORT:-80}"
|
||||
- "${HTTPS_BIND:-0.0.0.0}:${HTTPS_PORT:-443}:${HTTPS_PORT:-443}"
|
||||
- "${HTTP_BIND:-0.0.0.0}:${HTTP_PORT:-80}:${HTTP_PORT:-80}"
|
||||
restart: always
|
||||
networks:
|
||||
mailcow-network:
|
||||
|
@ -25,10 +25,29 @@ if cp --help 2>&1 | grep -q -i "busybox"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for bin in openssl curl docker-compose docker git awk sha1sum; do
|
||||
for bin in openssl curl docker git awk sha1sum; do
|
||||
if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi
|
||||
done
|
||||
|
||||
echo "checking docker compose version...";
|
||||
if docker --help | grep compose
|
||||
then
|
||||
echo ''
|
||||
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1
|
||||
then
|
||||
>&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
|
||||
>&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
|
||||
>&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
|
||||
>&2 echo
|
||||
>&2 echo
|
||||
>&2 echo -e "\e[33mContinuing...\e[0m"
|
||||
sleep 3
|
||||
|
||||
else
|
||||
>&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f mailcow.conf ]; then
|
||||
read -r -p "A config file exists and will be overwritten, are you sure you want to continue? [y/N] " response
|
||||
case $response in
|
||||
@ -144,7 +163,7 @@ DBROOT=$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 | head -c 28)
|
||||
# Do _not_ use IP:PORT in HTTP(S)_BIND or HTTP(S)_PORT
|
||||
# IMPORTANT: Do not use port 8081, 9081 or 65510!
|
||||
# Example: HTTP_BIND=1.2.3.4
|
||||
# For IPv4 and IPv6 leave it empty: HTTP_BIND= & HTTPS_PORT=
|
||||
# For IPv4 leave it as it is: HTTP_BIND= & HTTPS_PORT=
|
||||
# For IPv6 see https://mailcow.github.io/mailcow-dockerized-docs/post_installation/firststeps-ip_bindings/
|
||||
|
||||
HTTP_PORT=80
|
||||
|
@ -77,13 +77,33 @@ function preflight_local_checks() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for bin in rsync docker-compose docker grep cut; do
|
||||
for bin in rsync docker grep cut; do
|
||||
if [[ -z $(which ${bin}) ]]; then
|
||||
>&2 echo -e "\e[31mCannot find ${bin} in local PATH, exiting...\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
echo "checking docker compose version...";
|
||||
if docker --help | grep compose
|
||||
then
|
||||
echo ''
|
||||
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1
|
||||
then
|
||||
>&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
|
||||
>&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
|
||||
>&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
|
||||
>&2 echo
|
||||
>&2 echo
|
||||
>&2 echo -e "\e[33mContinuing...\e[0m"
|
||||
sleep 3
|
||||
|
||||
else
|
||||
>&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep --help 2>&1 | head -n 1 | grep -q -i "busybox"; then
|
||||
>&2 echo -e "\e[31mBusyBox grep detected on local system, please install GNU grep\e[0m"
|
||||
exit 1
|
||||
@ -111,7 +131,7 @@ function preflight_remote_checks() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for bin in rsync docker-compose docker; do
|
||||
for bin in rsync docker; do
|
||||
if ! ssh -o StrictHostKeyChecking=no \
|
||||
-i "${REMOTE_SSH_KEY}" \
|
||||
${REMOTE_SSH_HOST} \
|
||||
@ -122,6 +142,32 @@ function preflight_remote_checks() {
|
||||
fi
|
||||
done
|
||||
|
||||
echo "checking docker compose version on remote...";
|
||||
if ssh -q -o StrictHostKeyChecking=no \
|
||||
-i "${REMOTE_SSH_KEY}" \
|
||||
${REMOTE_SSH_HOST} \
|
||||
-p ${REMOTE_SSH_PORT} \
|
||||
-t docker --help | grep compose
|
||||
then
|
||||
COMPOSE_COMMAND="docker compose"
|
||||
elif ssh -q -o StrictHostKeyChecking=no \
|
||||
-i "${REMOTE_SSH_KEY}" \
|
||||
${REMOTE_SSH_HOST} \
|
||||
-p ${REMOTE_SSH_PORT} \
|
||||
'docker-compose version --short' | grep -m1 "^1" > /dev/null 2>&1
|
||||
then
|
||||
>&2 echo -e "\e[31mWARN: The remote is using Docker-Compose v1!\e[0m"
|
||||
>&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
|
||||
>&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2 on remote.\e[0m"
|
||||
>&2 echo
|
||||
>&2 echo
|
||||
>&2 echo -e "\e[33mContinuing...\e[0m"
|
||||
sleep 3
|
||||
COMPOSE_COMMAND="docker-compose"
|
||||
else
|
||||
>&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on the Remote Machine! Please install Docker-Compose v2 on that and re-run the script.\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
preflight_local_checks
|
||||
@ -252,16 +298,18 @@ if ! ssh -o StrictHostKeyChecking=no \
|
||||
fi
|
||||
echo "OK"
|
||||
|
||||
echo -e "\033[1mPulling images on remote...\033[0m"
|
||||
if ! ssh -o StrictHostKeyChecking=no \
|
||||
-i "${REMOTE_SSH_KEY}" \
|
||||
${REMOTE_SSH_HOST} \
|
||||
-p ${REMOTE_SSH_PORT} \
|
||||
docker-compose -f "${SCRIPT_DIR}/../docker-compose.yml" pull --no-parallel 2>&1 ; then
|
||||
>&2 echo -e "\e[31m[ERR]\e[0m - Could not pull images on remote"
|
||||
fi
|
||||
echo -e "\e[33mPulling images on remote...\e[0m"
|
||||
echo -e "\e[33mProcess is NOT stuck! Please wait...\e[0m"
|
||||
|
||||
echo -e "\033[1mForcing garbage cleanup on remote...\033[0m"
|
||||
if ! ssh -o StrictHostKeyChecking=no \
|
||||
-i "${REMOTE_SSH_KEY}" \
|
||||
${REMOTE_SSH_HOST} \
|
||||
-p ${REMOTE_SSH_PORT} \
|
||||
$COMPOSE_COMMAND -f "${SCRIPT_DIR}/../docker-compose.yml" pull --no-parallel --quiet 2>&1 ; then
|
||||
>&2 echo -e "\e[31m[ERR]\e[0m - Could not pull images on remote"
|
||||
fi
|
||||
|
||||
echo -e "\033[1mExecuting update script and forcing garbage cleanup on remote...\033[0m"
|
||||
if ! ssh -o StrictHostKeyChecking=no \
|
||||
-i "${REMOTE_SSH_KEY}" \
|
||||
${REMOTE_SSH_HOST} \
|
||||
|
@ -76,6 +76,31 @@ else
|
||||
CMPS_PRJ=$(echo ${COMPOSE_PROJECT_NAME} | tr -cd "[0-9A-Za-z-_]")
|
||||
fi
|
||||
|
||||
echo "checking docker compose version...";
|
||||
if docker --help | grep compose
|
||||
then
|
||||
COMPOSE_COMMAND="docker compose"
|
||||
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1
|
||||
then
|
||||
>&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
|
||||
>&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
|
||||
>&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
|
||||
>&2 echo
|
||||
>&2 echo
|
||||
>&2 echo -e "\e[33mContinuing...\e[0m"
|
||||
sleep 3
|
||||
COMPOSE_COMMAND="docker-compose"
|
||||
else
|
||||
>&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep --help 2>&1 | head -n 1 | grep -q -i "busybox"; then
|
||||
>&2 echo -e "\e[31mBusyBox grep detected on local system, please install GNU grep\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
function backup() {
|
||||
DATE=$(date +"%Y-%m-%d-%H-%M-%S")
|
||||
mkdir -p "${BACKUP_LOCATION}/mailcow-${DATE}"
|
||||
@ -226,7 +251,7 @@ function restore() {
|
||||
continue
|
||||
else
|
||||
echo "Stopping mailcow..."
|
||||
docker-compose -f ${COMPOSE_FILE} --env-file ${ENV_FILE} down
|
||||
${COMPOSE_COMMAND} -f ${COMPOSE_FILE} --env-file ${ENV_FILE} down
|
||||
fi
|
||||
#docker stop $(docker ps -qf name=mysql-mailcow)
|
||||
if [[ -d "${RESTORE_LOCATION}/mysql" ]]; then
|
||||
@ -264,7 +289,7 @@ function restore() {
|
||||
sed -i --follow-symlinks "/DBROOT/c\DBROOT=${DBROOT}" ${SCRIPT_DIR}/../mailcow.conf
|
||||
source ${SCRIPT_DIR}/../mailcow.conf
|
||||
echo "Starting mailcow..."
|
||||
docker-compose -f ${COMPOSE_FILE} --env-file ${ENV_FILE} up -d
|
||||
${COMPOSE_COMMAND} -f ${COMPOSE_FILE} --env-file ${ENV_FILE} up -d
|
||||
#docker start $(docker ps -aqf name=mysql-mailcow)
|
||||
fi
|
||||
;;
|
||||
|
89
update.sh
89
update.sh
@ -40,10 +40,31 @@ PATH=$PATH:/opt/bin
|
||||
|
||||
umask 0022
|
||||
|
||||
for bin in curl docker-compose docker git awk sha1sum; do
|
||||
for bin in curl docker git awk sha1sum; do
|
||||
if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi
|
||||
done
|
||||
|
||||
|
||||
echo "checking docker compose version...";
|
||||
if docker --help | grep compose
|
||||
then
|
||||
COMPOSE_COMMAND="docker compose"
|
||||
|
||||
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1
|
||||
then
|
||||
>&2 echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
|
||||
>&2 echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
|
||||
>&2 echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
|
||||
>&2 echo
|
||||
>&2 echo
|
||||
>&2 echo -e "\e[33mContinuing...\e[0m"
|
||||
sleep 3
|
||||
COMPOSE_COMMAND="docker-compose"
|
||||
|
||||
else
|
||||
>&2 echo -e "\e[31mCannot find Docker-Compose v1 or v2 on your System. Please install Docker-Compose v2 and re-run the Script.\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
export LC_ALL=C
|
||||
DATE=$(date +%Y-%m-%d_%H_%M_%S)
|
||||
BRANCH=$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD)
|
||||
@ -235,9 +256,6 @@ while (($#)); do
|
||||
echo -e "\e[32mRunning in forced mode...\e[0m"
|
||||
FORCE=y
|
||||
;;
|
||||
--no-update-compose)
|
||||
NO_UPDATE_COMPOSE=y
|
||||
;;
|
||||
--skip-ping-check)
|
||||
SKIP_PING_CHECK=y
|
||||
;;
|
||||
@ -247,7 +265,6 @@ while (($#)); do
|
||||
-c|--check - Check for updates and exit (exit codes => 0: update available, 3: no updates)
|
||||
--ours - Use merge strategy option "ours" to solve conflicts in favor of non-mailcow code (local changes over remote changes), not recommended!
|
||||
--gc - Run garbage collector to delete old image tags
|
||||
--no-update-compose - Do not update docker-compose
|
||||
--prefetch - Only prefetch new images and exit (useful to prepare updates)
|
||||
--skip-start - Do not start mailcow after update
|
||||
--skip-ping-check - Skip ICMP Check to public DNS resolvers (Use it only if you´ve blocked any ICMP Connections to your mailcow machine).
|
||||
@ -264,7 +281,7 @@ source mailcow.conf
|
||||
DOTS=${MAILCOW_HOSTNAME//[^.]};
|
||||
if [ ${#DOTS} -lt 2 ]; then
|
||||
echo "MAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is not a FQDN!"
|
||||
echo "Please change it to a FQDN and run docker-compose down followed by docker-compose up -d"
|
||||
echo "Please change it to a FQDN and run ${COMPOSE_COMMAND} down followed by ${COMPOSE_COMMAND} up -d"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -578,13 +595,13 @@ if [ ! $FORCE ]; then
|
||||
fi
|
||||
|
||||
echo -e "\e[32mValidating docker-compose stack configuration...\e[0m"
|
||||
if ! docker-compose config -q; then
|
||||
if ! ${COMPOSE_COMMAND} config -q; then
|
||||
echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\e[32mChecking for conflicting bridges...\e[0m"
|
||||
MAILCOW_BRIDGE=$(docker-compose config | grep -i com.docker.network.bridge.name | cut -d':' -f2)
|
||||
MAILCOW_BRIDGE=$(${COMPOSE_COMMAND} config | grep -i com.docker.network.bridge.name | cut -d':' -f2)
|
||||
while read NAT_ID; do
|
||||
iptables -t nat -D POSTROUTING $NAT_ID
|
||||
done < <(iptables -L -vn -t nat --line-numbers | grep $IPV4_NETWORK | grep -E 'MASQUERADE.*all' | grep -v ${MAILCOW_BRIDGE} | cut -d' ' -f1)
|
||||
@ -604,8 +621,8 @@ prefetch_images
|
||||
|
||||
echo -e "\e[32mStopping mailcow...\e[0m"
|
||||
sleep 2
|
||||
MAILCOW_CONTAINERS=($(docker-compose ps -q))
|
||||
docker-compose down
|
||||
MAILCOW_CONTAINERS=($(${COMPOSE_COMMAND} ps -q))
|
||||
${COMPOSE_COMMAND} down
|
||||
echo -e "\e[32mChecking for remaining containers...\e[0m"
|
||||
sleep 2
|
||||
for container in "${MAILCOW_CONTAINERS[@]}"; do
|
||||
@ -642,51 +659,16 @@ elif [[ ${MERGE_RETURN} == 1 ]]; then
|
||||
elif [[ ${MERGE_RETURN} != 0 ]]; then
|
||||
echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m"
|
||||
echo
|
||||
echo "Run docker-compose up -d to restart your stack without updates or try again after fixing the mentioned errors."
|
||||
echo "Run ${COMPOSE_COMMAND} up -d to restart your stack without updates or try again after fixing the mentioned errors."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${NO_UPDATE_COMPOSE} == "y" ]]; then
|
||||
echo -e "\e[33mNot fetching latest docker-compose, please check for updates manually!\e[0m"
|
||||
elif [[ -e /etc/alpine-release ]]; then
|
||||
echo -e "\e[33mNot fetching latest docker-compose, because you are using Alpine Linux without glibc support. Please update docker-compose via apk!\e[0m"
|
||||
else
|
||||
echo -e "\e[32mFetching new docker-compose version...\e[0m"
|
||||
echo -e "\e[32mTrying to determine GLIBC version...\e[0m"
|
||||
if ldd --version > /dev/null; then
|
||||
GLIBC_V=$(ldd --version | grep -E '(GLIBC|GNU libc)' | rev | cut -d ' ' -f1 | rev | cut -d '.' -f2)
|
||||
if [ ! -z "${GLIBC_V}" ] && [ ${GLIBC_V} -gt 27 ]; then
|
||||
DC_DL_SUFFIX=
|
||||
else
|
||||
DC_DL_SUFFIX=legacy
|
||||
fi
|
||||
else
|
||||
DC_DL_SUFFIX=legacy
|
||||
fi
|
||||
sleep 1
|
||||
if [[ ! -z $(which pip) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then
|
||||
true
|
||||
#prevent breaking a working docker-compose installed with pip
|
||||
elif [[ $(curl -sL -w "%{http_code}" https://www.servercow.de/docker-compose/latest.php?vers=${DC_DL_SUFFIX} -o /dev/null) == "200" ]]; then
|
||||
LATEST_COMPOSE=$(curl -#L https://www.servercow.de/docker-compose/latest.php)
|
||||
COMPOSE_VERSION=$(docker-compose version --short)
|
||||
if [[ "$LATEST_COMPOSE" != "$COMPOSE_VERSION" ]]; then
|
||||
COMPOSE_PATH=$(which docker-compose)
|
||||
if [[ -w ${COMPOSE_PATH} ]]; then
|
||||
curl -#L https://github.com/docker/compose/releases/download/${LATEST_COMPOSE}/docker-compose-$(uname -s)-$(uname -m) > $COMPOSE_PATH
|
||||
chmod +x $COMPOSE_PATH
|
||||
else
|
||||
echo -e "\e[33mWARNING: $COMPOSE_PATH is not writable, but new version $LATEST_COMPOSE is available (installed: $COMPOSE_VERSION)\e[0m"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "\e[33mCannot determine latest docker-compose version, skipping...\e[0m"
|
||||
fi
|
||||
fi
|
||||
echo -e "\e[33mNot fetching latest docker-compose, please check for updates manually!\e[0m"
|
||||
sleep 3
|
||||
|
||||
echo -e "\e[32mFetching new images, if any...\e[0m"
|
||||
sleep 2
|
||||
docker-compose pull
|
||||
${COMPOSE_COMMAND} pull
|
||||
|
||||
# Fix missing SSL, does not overwrite existing files
|
||||
[[ ! -d data/assets/ssl ]] && mkdir -p data/assets/ssl
|
||||
@ -707,9 +689,6 @@ fi
|
||||
|
||||
# Checking for old project name bug
|
||||
sed -i --follow-symlinks 's#COMPOSEPROJECT_NAME#COMPOSE_PROJECT_NAME#g' mailcow.conf
|
||||
# Checking old, wrong bindings
|
||||
sed -i --follow-symlinks 's/HTTP_BIND=0.0.0.0/HTTP_BIND=/g' mailcow.conf
|
||||
sed -i --follow-symlinks 's/HTTPS_BIND=0.0.0.0/HTTPS_BIND=/g' mailcow.conf
|
||||
|
||||
# Fix Rspamd maps
|
||||
if [ -f data/conf/rspamd/custom/global_from_blacklist.map ]; then
|
||||
@ -744,11 +723,11 @@ else
|
||||
fi
|
||||
|
||||
if [[ ${SKIP_START} == "y" ]]; then
|
||||
echo -e "\e[33mNot starting mailcow, please run \"docker-compose up -d --remove-orphans\" to start mailcow.\e[0m"
|
||||
echo -e "\e[33mNot starting mailcow, please run \"${COMPOSE_COMMAND} up -d --remove-orphans\" to start mailcow.\e[0m"
|
||||
else
|
||||
echo -e "\e[32mStarting mailcow...\e[0m"
|
||||
sleep 2
|
||||
docker-compose up -d --remove-orphans
|
||||
${COMPOSE_COMMAND} up -d --remove-orphans
|
||||
fi
|
||||
|
||||
echo -e "\e[32mCollecting garbage...\e[0m"
|
||||
@ -763,4 +742,4 @@ fi
|
||||
#echo
|
||||
#git reflog --color=always | grep "Before update on "
|
||||
#echo
|
||||
#echo "Use \"git reset --hard hash-on-the-left\" and run docker-compose up -d afterwards."
|
||||
#echo "Use \"git reset --hard hash-on-the-left\" and run ${COMPOSE_COMMAND} up -d afterwards."
|
||||
|
Loading…
Reference in New Issue
Block a user