Skip to content

Commit

Permalink
Correct various bugs on circus, in particular in passing env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
adferrand committed Sep 12, 2018
1 parent a7fd5b6 commit 5dca16b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 48 deletions.
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ ENV BACKUPPC_XS_VERSION 0.57
ENV RSYNC_BPC_VERSION 3.0.9.12
ENV PAR2_VERSION v0.8.0

RUN apk --no-cache --update add python3 rsync perl perl-archive-zip perl-xml-rss perl-cgi perl-file-listing expat samba-client iputils openssh openssl rrdtool msmtp lighttpd lighttpd-mod_auth gzip apache2-utils tzdata libstdc++ libgomp shadow \
# Install backuppc runtime dependencies
RUN apk --no-cache --update add python3 rsync bash perl perl-archive-zip perl-xml-rss perl-cgi perl-file-listing expat samba-client iputils openssh openssl rrdtool msmtp lighttpd lighttpd-mod_auth gzip apache2-utils tzdata libstdc++ libgomp shadow \
# Install backuppc build dependencies
&& apk --no-cache --update --virtual build-dependencies add gcc g++ libgcc autoconf automake make git patch perl-dev expat-dev curl wget \
&& apk --no-cache --update --virtual build-dependencies add gcc g++ libgcc linux-headers autoconf automake make git patch perl-dev python3-dev expat-dev curl wget \
# Install supervisor
&& python3 -m ensurepip \
&& pip3 install --upgrade pip circus \
Expand All @@ -32,21 +33,24 @@ RUN apk --no-cache --update add python3 rsync perl perl-archive-zip perl-xml-rss
# Get BackupPC, it will be installed at runtime to allow dynamic upgrade of existing config/pool
&& curl -o /root/BackupPC-$BACKUPPC_VERSION.tar.gz -L https://github.com/backuppc/backuppc/releases/download/$BACKUPPC_VERSION/BackupPC-$BACKUPPC_VERSION.tar.gz \
# Prepare backuppc home
&& mkdir -p /home/backuppc \
# Mark the docker as not runned yet, to allow entrypoint to do its stuff
&& mkdir -p /home/backuppc && cd /home/backuppc \
# Mark the docker as not run yet, to allow entrypoint to do its stuff
&& touch /firstrun \
# Clean
&& rm -rf /root/backuppc-xs /root/rsync-bpc /root/par2cmdline \
&& apk del build-dependencies

COPY files/lighttpd.conf /etc/lighttpd/lighttpd.conf
COPY files/entrypoint.sh /entrypoint.sh
COPY files/run.sh /run.sh
COPY files/circus.ini /etc/circus.ini

EXPOSE 8080

WORKDIR /home/backuppc

VOLUME ["/etc/backuppc", "/home/backuppc", "/data/backuppc"]

ENTRYPOINT ["/entrypoint.sh"]

CMD ["/usr/bin/circusd", "/etc/circus.ini"]
CMD ["/run.sh"]
9 changes: 8 additions & 1 deletion files/circus.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ endpoint = ipc:///var/circus/endpoint
pubsub_endpoint = ipc:///var/circus/pubsub
statsd = False
httpd = False
working_dir = /home/backuppc

[watcher:lighttpd]
cmd = /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -D
Expand All @@ -12,4 +13,10 @@ stderr_stream.class = FancyStdoutStream
[watcher:backuppc]
cmd = /usr/local/BackupPC/bin/BackupPC
stdout_stream.class = FancyStdoutStream
stderr_stream.class = FancyStdoutStream
stderr_stream.class = FancyStdoutStream
uid = $(circus.env.backuppc_uuid)
gid = $(circus.env.backuppc_guid)

[env:lighttpd]
BACKUPPC_USERNAME = $BACKUPPC_USERNAME
BACKUPPC_GROUPNAME = $BACKUPPC_GROUPNAME
16 changes: 12 additions & 4 deletions files/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/sh
set -e

BACKUPPC_USERNAME=`getent passwd "${BACKUPPC_UUID:-1000}" | cut -d: -f1`
BACKUPPC_GROUPNAME=`getent group "${BACKUPPC_GUID:-1000}" | cut -d: -f1`
BACKUPPC_UUID="${BACKUPPC_UUID:-1000}"
BACKUPPC_GUID="${BACKUPPC_GUID:-1000}"
BACKUPPC_USERNAME=`getent passwd "$BACKUPPC_UUID" | cut -d: -f1`
BACKUPPC_GROUPNAME=`getent group "$BACKUPPC_GUID" | cut -d: -f1`

if [ -f /firstrun ]; then
echo 'First run of the container. BackupPC will be installed.'
Expand All @@ -15,11 +17,11 @@ if [ -f /firstrun ]; then

# Create backuppc user/group if needed
if [ -z "$BACKUPPC_GROUPNAME" ]; then
groupadd -r -g "${BACKUPPC_GUID:-1000}" backuppc
groupadd -r -g "$BACKUPPC_GUID" backuppc
BACKUPPC_GROUPNAME="backuppc"
fi
if [ -z "$BACKUPPC_USERNAME" ]; then
useradd -r -d /home/backuppc -g "${BACKUPPC_GUID:-1000}" -u ${BACKUPPC_UUID:-1000} -M -N backuppc
useradd -r -d /home/backuppc -g "$BACKUPPC_GUID" -u "$BACKUPPC_UUID" -M -N backuppc
BACKUPPC_USERNAME="backuppc"
else
usermod -d /home/backuppc "$BACKUPPC_USERNAME"
Expand Down Expand Up @@ -92,8 +94,14 @@ if [ -f /firstrun ]; then
rm -rf /root/BackupPC-$BACKUPPC_VERSION.tar.gz /root/BackupPC-$BACKUPPC_VERSION /firstrun
fi

export BACKUPPC_UUID
export BACKUPPC_GUID
export BACKUPPC_USERNAME
export BACKUPPC_GROUPNAME

# Executable bzip2 seems to have been moved into /usr/bin in latest Alpine version. Fix that.
ln -s /usr/bin/bzip2 /bin/bzip2

# Exec given CMD in Dockerfile
cd /home/backuppc
exec "$@"
8 changes: 8 additions & 0 deletions files/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Ensure directory and necessary sockets exists
mkdir -p /var/circus
touch /var/circus/endpoint /var/circus/pubsub /var/circus/stats

# Launch circus
/usr/bin/circusd /etc/circus.ini
38 changes: 0 additions & 38 deletions files/supervisord.conf

This file was deleted.

0 comments on commit 5dca16b

Please sign in to comment.