This commit is contained in:
buanet
2021-08-30 19:20:17 +02:00
parent 904058c0f5
commit 97ca3aa72d
7 changed files with 124 additions and 120 deletions

View File

@@ -65,7 +65,7 @@ jobs:
uses: docker/build-push-action@v2.6.1
with:
context: ./debian
file: ./debian/Dockerfile-amd64
file: ./debian/node12/Dockerfile
push: true
platforms: linux/amd64
tags: |
@@ -76,7 +76,7 @@ jobs:
uses: docker/build-push-action@v2.6.1
with:
context: ./debian
file: ./debian/Dockerfile-arm32v7
file: ./debian/node12/Dockerfile
push: true
platforms: linux/arm/v7
tags: |
@@ -87,7 +87,7 @@ jobs:
uses: docker/build-push-action@v2.6.1
with:
context: ./debian
file: ./debian/Dockerfile-arm64v8
file: ./debian/node12/Dockerfile
push: true
platforms: linux/arm64/v8
tags: |

View File

@@ -1,11 +1,13 @@
## Changelog
### * v5.2.0-beta2 (2021-08-28)
* redesign maintenance script
* switching amd64 base image to debian bullseye slim
* optimizing log output
* adding labels in OCI standard format
* adding packages update on first start
* adding file for docker detection by ioBroker adapters
* adding best practice for states db migation
* adding best practice for states db migation in readme
* removing couchdb option for states db (no longer supported)
* v5.2.0-beta1 (2021-05-04)
* added upgrade parameter to maintenance script

View File

@@ -129,9 +129,39 @@ upgrade() {
fi
}
##############################
##### parsing parameters #####
##############################
########################################
##### parsing commands and options #####
########################################
for i in "$@"; do
case $i in
help|-h|--help)
display_help # calling function to display help text
exit
;;
status)
check_status # calling function to check maintenance mode status
;;
-y|--yes)
autoconfirm=yes # answers prompts with "yes"
;;
on|-on)
switch_on # calling function to switch maintenance mode on
exit
;;
-a=*|--argument=*) # dummy exaple for parsing option with value
ARGUMENT="${i#*=}"
shift
;;
-?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1"
;;
*) # Default case: No more options, so break out of the loop.
break
;;
esac
done
while :; do
case $1 in
-h|--help)

View File

@@ -1,83 +0,0 @@
FROM debian:bullseye-slim
LABEL org.opencontainers.image.title="ioBroker Docker Image" \
org.opencontainers.image.description="Docker image for ioBroker smarthome software" \
org.opencontainers.image.authors="info@buanet.de" \
org.opencontainers.image.url="https://github.com/buanet/ioBroker.docker" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.created="${DATI}"
ENV DEBIAN_FRONTEND noninteractive
# Install prerequisites
RUN apt-get update && apt-get install -y \
curl \
gosu \
jq \
locales \
procps \
sudo \
udev \
wget \
&& rm -rf /var/lib/apt/lists/*
# Install node
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \
&& apt-get update && apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Generating locales
RUN sed -i 's/^# *\(de_DE.UTF-8\)/\1/' /etc/locale.gen \
&& sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
&& locale-gen
# Create scripts directorys and copy scripts
RUN mkdir -p /opt/scripts/ \
&& mkdir -p /opt/userscripts/ \
&& chmod 777 /opt/scripts/ \
&& chmod 777 /opt/userscripts/
WORKDIR /opt/scripts/
COPY scripts/* ./
RUN chmod +x *.sh
WORKDIR /opt/userscripts/
COPY scripts/* ./
RUN chmod +x *.sh
# Install ioBroker
WORKDIR /
RUN apt-get update \
&& curl -sL https://iobroker.net/install.sh | bash - \
&& mkdir -p /opt/scripts/.docker_config/ \
&& echo $(hostname) > /opt/scripts/.docker_config/.install_host \
&& echo "starting" > /opt/scripts/.docker_config/.healthcheck \
&& echo $(hostname) > /opt/.firstrun \
&& rm -rf /var/lib/apt/lists/*
# Backup initial ioBroker and userscript folder
RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \
&& tar -cf /opt/initial_userscripts.tar /opt/userscripts
# Setting up iobroker-user (shell and home directory)
RUN chsh -s /bin/bash iobroker \
&& usermod --home /opt/iobroker iobroker \
&& usermod -u 1000 iobroker \
&& groupmod -g 1000 iobroker
# Setting up ENVs
ENV DEBIAN_FRONTEND="teletype" \
LANG="de_DE.UTF-8" \
LANGUAGE="de_DE:de" \
LC_ALL="de_DE.UTF-8" \
SETGID=1000 \
SETUID=1000 \
TZ="Europe/Berlin"
# Expose default admin ui port
EXPOSE 8081
# Healthcheck
HEALTHCHECK --interval=15s --timeout=5s --retries=5 \
CMD ["/bin/bash", "-c", "/opt/scripts/healthcheck.sh"]
# Run startup-script
ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"]

View File

@@ -22,7 +22,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*
# Install node
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash \
&& apt-get update && apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -1,6 +1,17 @@
#!/bin/bash
# function to display help text
############################
##### default settings #####
############################
autoconfirm=no # yould be set to true by commandline option
####################################
##### declaration of functions #####
####################################
# display help text
display_help() {
echo "This script is build to manage your ioBroker container!"
echo "Usage: maintenance [ COMMAND ] [ OPTIONS ]"
@@ -21,32 +32,41 @@ display_help() {
exit 0
}
while getopts h opt
do
case $opt in
h | --help)
display_help ;;
esac
exit 0;
done
if [ "$1" == "status" ]
then
# checking maintenance mode status
check_status() {
if [ $(cat /opt/scripts/.docker_config/.healthcheck) == 'maintenance' ]
then
echo 'Maintenance mode is ON.'
exit 0
echo 'Maintenance mode is turned ON.'
elif [ $(cat /opt/scripts/.docker_config/.healthcheck) != 'maintenance' ]
then
echo 'Maintenance mode is OFF.'
exit 0
echo 'Maintenance mode is turned OFF.'
fi
elif [ "$1" == "on" ]
then
echo 'You are now going to stop ioBroker and activating maintenance mode for this container.'
read -p 'Do you want to continue [yes/no]? ' A
if [ "$A" == "y" ] || [ "$A" == "Y" ] || [ "$A" == "yes" ]
}
# turn maintenance mode ON
switch_on() {
if [ $(cat /opt/scripts/.docker_config/.healthcheck) != 'maintenance' ] && [ "$autoconfirm" == "no" ] # maintenance mode OFF / autoconfirm = no
then
echo 'You are now going to stop ioBroker and activating maintenance mode for this container.'
read -p 'Do you want to continue [yes/no]? ' A
if [ "$A" == "y" ] || [ "$A" == "Y" ] || [ "$A" == "yes" ]
then
echo 'Activating maintenance mode...'
echo "maintenance" > /opt/scripts/.docker_config/.healthcheck
sleep 1
echo 'Done.'
echo 'Stopping ioBroker...'
pkill -u iobroker
sleep 1
echo 'Done.'
exit 0
else
exit 0
fi
elif [ $(cat /opt/scripts/.docker_config/.healthcheck) != 'maintenance' ] && [ "$autoconfirm" == "yes" ] # maintenance mode OFF / autoconfirm = yes
then
echo 'You are now going to stop ioBroker and activating maintenance mode for this container.'
echo 'This command was already confirmed by -y or --yes option.'
echo 'Activating maintenance mode...'
echo "maintenance" > /opt/scripts/.docker_config/.healthcheck
sleep 1
@@ -57,10 +77,12 @@ then
echo 'Done.'
exit 0
else
exit 0
echo 'Maintenance mode is already turned ON.'
fi
elif [ "$1" == "off" ]
then
}
# turn maintenance mode OFF
switch_off() {
echo 'You are now going to deactivate maintenance mode for this container.'
echo 'Depending on the restart policy, your container will be stopped/ restarted immediately.'
read -p 'Do you want to continue [yes/no]? ' A
@@ -73,8 +95,10 @@ then
else
exit 0
fi
elif [ "$1" == "upgrade" ]
then
}
# upgrade js-controller
upgrade() {
echo 'You are now going to upgrade your js-controller.'
echo 'As this will change data in /opt/iobroker, make sure you have a backup!'
echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.'
@@ -103,8 +127,39 @@ then
else
exit 0
fi
else
echo 'Invalid command. Please try again.'
fi
}
##############################
##### parsing parameters #####
##############################
while :; do
case $1 in
-h|--help)
display_help # calling function to display help text
exit
;;
-y|--yes)
autoconfirm=yes # answers prompts with "yes"
;;
status)
check_status # calling function to check maintenance mode status
;;
on|-on)
switch_on # calling function to switch maintenance mode on
exit
;;
--) # End of all options.
shift
break
;;
-?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1"
;;
*) # Default case: No more options, so break out of the loop.
break
esac
shift
done
exit 0