diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2019-01-17 08:56:48 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2019-01-17 12:16:53 +0100 |
| commit | 96ce7d938bb7ab2fc1520f703ceddc8e3355ce3f (patch) | |
| tree | f735939e017501e8a4f86f39a597e83ad00ad5db /script/docker-build.sh | |
| parent | 13d319d72cc44db35490fd34a71fa69269397668 (diff) | |
| download | jo.mssola.com-96ce7d938bb7ab2fc1520f703ceddc8e3355ce3f.tar.gz jo.mssola.com-96ce7d938bb7ab2fc1520f703ceddc8e3355ce3f.zip | |
Dockerized deployment method
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'script/docker-build.sh')
| -rwxr-xr-x | script/docker-build.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/script/docker-build.sh b/script/docker-build.sh new file mode 100755 index 0000000..8aa1590 --- /dev/null +++ b/script/docker-build.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Copyright (C) 2019 Miquel Sabaté Solà <mikisabate@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +set -ex + +# If the image does not exist, build it. +IMGTAG=mssola/jo:latest +[ ! -z $(docker images -q $IMGTAG) ] || docker build -t $IMGTAG . + +# The user which should own the produced files. +user=$(id -u `whoami`) +group=$(id -g `whoami`) + +# The -it flag should not be set on the post-receive hook because there's no TTY +# there. +IT="-it" +if [ "$POST_RECEIVE" = "true" ]; then + IT= +fi + +# And now the call... +docker run --rm $IT \ + -e BUILD_SOURCE=/src -e BUILD_DEST=/dest \ + -e BUNDLE_GEMFILE=/src/Gemfile -e USER=$user -e GROUP=$group \ + -e NODE_ENV=development -e NUKE=$NUKE \ + -v $BUILD_SOURCE:/src -v $BUILD_DEST:/dest \ + $IMGTAG /src/script/build.sh |
