To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / deploy / docker / start.sh @ 1589:94669513c53c
History | View | Annotate | Download (1.71 KB)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
|
| 3 |
mydir=$(dirname "$0") |
| 4 |
|
| 5 |
dbpwd="$1" |
| 6 |
if [ -z "$dbpwd" ]; then |
| 7 |
echo "Usage: $0 <database-password>" 1>&2 |
| 8 |
exit 2 |
| 9 |
fi |
| 10 |
|
| 11 |
set -eu -o pipefail |
| 12 |
|
| 13 |
rootdir="$mydir/../.." |
| 14 |
|
| 15 |
deploydir="$rootdir"/deploy |
| 16 |
if [ ! -d "$deploydir" ]; then |
| 17 |
echo "ERROR: Unexpected repository layout - expected directory at $deploydir" |
| 18 |
exit 2 |
| 19 |
fi |
| 20 |
|
| 21 |
managerdir="$deploydir/docker" |
| 22 |
if [ ! -d "$managerdir" ]; then |
| 23 |
echo "ERROR: Required directory $managerdir not found" |
| 24 |
exit 2 |
| 25 |
fi |
| 26 |
|
| 27 |
configdir="$deploydir/config" |
| 28 |
if [ ! -d "$configdir" ]; then |
| 29 |
echo "ERROR: Required directory $configdir not found" |
| 30 |
exit 2 |
| 31 |
fi |
| 32 |
|
| 33 |
if [ ! -f "$rootdir/postgres-dumpall" ]; then |
| 34 |
echo "ERROR: I expect to find a Postgres SQL multi-db dump file in $rootdir/postgres-dumpall" |
| 35 |
exit 2 |
| 36 |
fi |
| 37 |
|
| 38 |
fontdir="$rootdir"/public/themes/soundsoftware/stylesheets/fonts |
| 39 |
if [ ! -f "$fontdir/24BC0E_0_0.woff" ]; then |
| 40 |
echo "ERROR: I expect to find necessary webfonts in $fontdir" |
| 41 |
exit 2 |
| 42 |
fi |
| 43 |
|
| 44 |
for f in database.yml code.conf ; do |
| 45 |
cat "$configdir/$f.in" | |
| 46 |
sed 's/INSERT_POSTGRES_PASSWORD_HERE/'"$dbpwd"'/g' > \ |
| 47 |
"$configdir/$f" |
| 48 |
done |
| 49 |
|
| 50 |
provisioning_commands=$( |
| 51 |
for x in "$deploydir"/provision.d/[0-9]*; do |
| 52 |
echo "RUN /bin/bash /var/www/code/deploy/provision.d/$(basename $x)" |
| 53 |
done | sed 's/$/\\n/' | fmt -2000 | sed 's/ RUN/RUN/g' ) |
| 54 |
|
| 55 |
( echo |
| 56 |
echo "### DO NOT EDIT THIS FILE - it is generated from Dockerfile.in" |
| 57 |
echo |
| 58 |
) > "$managerdir/Dockerfile" |
| 59 |
|
| 60 |
cat "$managerdir/Dockerfile.in" | |
| 61 |
sed 's,INSERT_PROVISIONING_HERE,'"$provisioning_commands"',' >> \ |
| 62 |
"$managerdir/Dockerfile" |
| 63 |
|
| 64 |
cd "$rootdir" |
| 65 |
|
| 66 |
dockertag="cannam/soundsoftware-site" |
| 67 |
|
| 68 |
sudo docker build -t "$dockertag" -f "deploy/docker/Dockerfile" . |
| 69 |
sudo docker run -p 8080:80 -d "$dockertag" |
| 70 |
|