Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile #653

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions actions/Dockerfile
Original file line number Diff line number Diff line change
@@ -212,6 +212,6 @@ RUN chown bluecherry.bluecherry -R /var/lib/bluecherry
#CMD rm -f /var/run/rsyslogd.pid
#CMD ["/usr/sbin/rsyslogd", "-n", "-f", "/etc/rsyslog.conf"]
#CMD service rsyslog start
CMD /usr/sbin/php-fpm7.4 -D
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
CMD "/entrypoint.sh"
#CMD /usr/sbin/php-fpm7.4 -D
#CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
ENTRYPOINT ["/entrypoint.sh"]
52 changes: 36 additions & 16 deletions actions/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ echo "> Writing /root/.my.cnf"
echo "[mysqldump]"; \
echo "user=$MYSQL_ADMIN_LOGIN"; \
echo "password=$MYSQL_ADMIN_PASSWORD"; \
echo "host=$BLUECHERRY_DB_HOST"; \
echo "[mysqldiff]"; \
echo "user=$MYSQL_ADMIN_LOGIN"; \
echo "password=$MYSQL_ADMIN_PASSWORD"; \
@@ -45,20 +44,38 @@ echo "> chown bluecherry:bluecherry /var/lib/bluecherry/recordings"
chown bluecherry:bluecherry /var/lib/bluecherry/recordings
chown -R bluecherry:bluecherry /var/lib/bluecherry/.local/share/data/


# The bluecherry container's Dockerfile sets rsyslog to route the bluecherry
# server's main log file to STDOUT for process #1, which then gets picked up
# by docker (so its messages get routed out through docker logs, etc.), but
# the location permissions have to be reset on every start of the container:
chmod 777 /proc/self/fd/1

sleep 15

license_key=$(mysql bluecherry -e "SELECT license FROM Licenses;" | tail -n +2 | awk '{print $1}')
echo "License key: $license_key"

deactivate_license() {
echo "Deactivating license..."
/usr/lib/bluecherry/licensecmd bc_v3_license_DeactivateLicense $license_key
}

on_exit() {
echo "Container is shutting down..."
# Place your command to run before exit here
# deactivate_license $license_key
/usr/lib/bluecherry/licensecmd bc_v3_license_DeactivateLicense $license_key
exit 0
}

# Hack to fix race condition where rsyslog starts too soon and throws errors
# https://github.com/bluecherrydvr/bluecherry-docker/issues/26

# sleep for 5 for good measure
sleep 5

echo "> /usr/sbin/rsyslogd"

# rm rsyslog.pid to prevent respawning
rm -f /run/rsyslogd.pid
/usr/sbin/rsyslogd
@@ -72,7 +89,6 @@ exec "$@"

/etc/init.d/php7.4-fpm start


echo "> /usr/sbin/nginx"
#source /etc/apache2/envvars
/usr/sbin/nginx
@@ -82,6 +98,7 @@ if [ $status -ne 0 ]; then
exit $status
fi

trap 'on_exit' SIGTERM SIGINT

echo "> /usr/sbin/bc-server -u bluecherry -g bluecherry"
export LD_LIBRARY_PATH=/usr/lib/bluecherry
@@ -98,18 +115,21 @@ fi
# more than one service in a container. The container exits with an error
# if it detects that any of the processes has exited.
# Otherwise it loops forever, waking up every 15 seconds

while sleep 15; do
ps aux |grep rsyslog |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep nginx |grep -q -v grep
PROCESS_2_STATUS=$?
ps aux |grep bc-server |grep -q -v grep
PROCESS_3_STATUS=$?

# If the greps above find anything, they exit with 0 status
# If they are not both 0, then something is wrong
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 -o $PROCESS_3_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
if ! pgrep -x rsyslog > /dev/null; then
echo "rsyslog has exited."
break
fi
if ! pgrep -x nginx > /dev/null; then
echo "nginx has exited."
break
fi
if ! pgrep -x bc-server > /dev/null; then
echo "bc-server has exited."
break
fi
done

# Deactivate license on docker stop.
on_exit