Skip to content

Commit baf72a8

Browse files
committed
Added an entrypoint script to the backup service
1 parent 112b2f8 commit baf72a8

File tree

7 files changed

+58
-11
lines changed

7 files changed

+58
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.ruby-version

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
docker-images
1+
Docker Images
22
=============
3+
4+
These are a collection of Docker images I use to deploy and support various projects I am working on.

backup-service/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,17 @@ RUN gem install backup rubygems-update whenever --no-ri --no-rdoc
8181
# Clean up APT when done.
8282
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
8383

84+
# Add the entrypoint script
85+
ADD ./entrypoint /opt/backups/entrypoint
86+
8487
# Define working directory.
85-
WORKDIR /data
88+
WORKDIR /opt/backups
8689

8790
# Define mountable directories.
8891
VOLUME ["/data"]
8992

93+
# Define entrypoint script.
94+
ENTRYPOINT ["./entrypoint"]
95+
9096
# Use baseimage-docker's init system.
9197
CMD ["/sbin/my_init"]

backup-service/entrypoint

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Set environment variables
5+
export BACKUP_DATA_DIR="${BACKUP_DATA_DIR:-`pwd`}"
6+
export BACKUP_CONFIG_DIR="${BACKUP_CONFIG_DIR:-`pwd`}"
7+
export BACKUP_COMMAND="${1:-init}"
8+
9+
# Make sure the specified directories are present
10+
mkdir -p "${BACKUP_DATA_DIR}"
11+
mkdir -p "${BACKUP_CONFIG_DIR}"
12+
13+
# Check for a known command
14+
BACKUP_COMMAND=$1
15+
case "${BACKUP_COMMAND}" in
16+
"trigger" )
17+
shift
18+
TASK=$1 && shift
19+
# Execute the backup command
20+
command="exec backup perform --config-file=${BACKUP_CONFIG_DIR}/config.rb --root-path=${BACKUP_DATA_DIR} --trigger ${TASK}"
21+
;;
22+
"schedule"|"scheduler"|"cron" )
23+
shift
24+
# Write the crontab entries from the whenever schedule
25+
whenever --load-file "${BACKUP_CONFIG_DIR}/schedule.rb" > "/etc/cron.d/backups"
26+
# Call the phusion baseimage init docker to start the various daemons including crond
27+
command="/sbin/my_init"
28+
;;
29+
"init" )
30+
# Call the phusion baseimage init docker to start the various daemons including crond
31+
command="/sbin/my_init"
32+
;;
33+
* )
34+
command="$@"
35+
;;
36+
esac
37+
38+
${command}

rails-app-base/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ RUN gem install bundler rubygems-update --no-ri --no-rdoc
7676
# Clean up APT when done.
7777
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
7878

79-
# Define mountable directories.
80-
VOLUME ["/data"]
81-
8279
# Define working directory.
8380
WORKDIR /data
81+
82+
# Define mountable directories.
83+
VOLUME ["/data"]

redis-commander/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ RUN npm install -g redis-commander
3737
# Clean up APT when done.
3838
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3939

40-
# Define mountable directories.
41-
VOLUME ["/data"]
42-
4340
# Define working directory.
4441
WORKDIR /data
4542

43+
# Define mountable directories.
44+
VOLUME ["/data"]
45+
4646
# Define default command.
4747
ENTRYPOINT ["redis-commander"]
4848

wordpress-base/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ RUN \
3131
# Clean up APT when done.
3232
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3333

34-
# Define mountable directories.
35-
VOLUME ["/data"]
36-
3734
# Define working directory.
3835
WORKDIR /data
3936

37+
# Define mountable directories.
38+
VOLUME ["/data"]
39+
4040
# Define default command.
4141
CMD ["php5-fpm", "-c", "/etc/php5/fpm/php.ini", "-y", "/etc/php5/fpm/php-fpm.conf", "-R"]
4242

0 commit comments

Comments
 (0)