Better scripts & description for dockerisation
This commit is contained in:
9
docker/README.md
Normal file
9
docker/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# MyData dockerisation
|
||||
|
||||
To create a Docker image for MyData + OpenData, do the following:
|
||||
|
||||
- Make sure that the `production` branch of both MyData and OpenData is up to date.
|
||||
Whatever is in that branch *on the Git server* is what will be packaged in the Docker image.
|
||||
- Run `./prep_elastic.sh` to download ElasticSearch, strip it down, and configure it.
|
||||
- Run `./prep_docker_img.sh` to prepare mydata & opendata for dockerisation.
|
||||
- Run `./build_docker_img.sh` to build & push the Docker image.
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
DEPLOY_BRANCH=${DEPLOY_BRANCH:-production}
|
||||
DOCKER_TAG="armadillica/blender-mydata"
|
||||
PROJECT_NAME="mydata"
|
||||
|
||||
# macOS does not support readlink -f, so we use greadlink instead
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
@@ -13,71 +15,17 @@ fi
|
||||
MY_DIR="$(dirname "$($readlink -f "$0")")"
|
||||
cd "$MY_DIR"
|
||||
|
||||
ROOT="$(dirname "$MY_DIR")"
|
||||
DEPLOYDIR="$ROOT/docker/deploy"
|
||||
PROJECT_NAME="mydata"
|
||||
|
||||
if [ -e "$DEPLOYDIR" ]; then
|
||||
echo "$DEPLOYDIR already exists, press [ENTER] to DESTROY AND COPY, Ctrl+C to abort."
|
||||
read dummy
|
||||
rm -rf "$DEPLOYDIR"
|
||||
else
|
||||
echo -n "Deploying to $DEPLOYDIR… "
|
||||
echo "press [ENTER] to continue, Ctrl+C to abort."
|
||||
read dummy
|
||||
fi
|
||||
|
||||
mkdir -p $DEPLOYDIR
|
||||
REMOTE_ROOT="$DEPLOYDIR/$PROJECT_NAME"
|
||||
|
||||
# Check that production branch has been pushed.
|
||||
if [ -n "$(git log origin/$DEPLOY_BRANCH..$DEPLOY_BRANCH --oneline)" ]; then
|
||||
echo "WARNING: not all changes to the $DEPLOY_BRANCH branch have been pushed."
|
||||
echo "Press [ENTER] to continue deploying current origin/$DEPLOY_BRANCH, CTRL+C to abort."
|
||||
read dummy
|
||||
fi
|
||||
|
||||
function git_clone() {
|
||||
REPO_NAME="$1"
|
||||
URL="$2"
|
||||
BRANCH="$DEPLOY_BRANCH"
|
||||
|
||||
set -e
|
||||
echo "==================================================================="
|
||||
echo "CLONING REPO ON $REPO_NAME @$BRANCH"
|
||||
git -C "$DEPLOYDIR" clone --depth 1 --branch $BRANCH $URL $REPO_NAME
|
||||
git -C "$DEPLOYDIR/$REPO_NAME" submodule init
|
||||
git -C "$DEPLOYDIR/$REPO_NAME" submodule update --recommend-shallow
|
||||
|
||||
# We need *some* settings to be able to run `manage.py collectstatic` later.
|
||||
# That command is given while building the docker image.
|
||||
cp "$MY_DIR/deploytime-settings-$REPO_NAME.py" $DEPLOYDIR/$REPO_NAME/$REPO_NAME/settings.py
|
||||
}
|
||||
|
||||
git_clone mydata git@gitlab.com:armadillica/blender-my-data.git
|
||||
git_clone opendata git@gitlab.com:armadillica/blender-open-data.git
|
||||
|
||||
# Gulp everywhere
|
||||
|
||||
# TODO: reinstate this, because it's much faster:
|
||||
# GULP=$ROOT/node_modules/.bin/gulp
|
||||
# if [ ! -e $GULP -o gulpfile.js -nt $GULP ]; then
|
||||
# npm install
|
||||
# touch $GULP # installer doesn't always touch this after a build, so we do.
|
||||
# fi
|
||||
# $GULP --cwd $DEPLOYDIR/mydata --production
|
||||
# $GULP --cwd $DEPLOYDIR/opendata --production
|
||||
|
||||
pushd "$DEPLOYDIR/mydata"
|
||||
./gulp
|
||||
rm -rf node_modules
|
||||
popd
|
||||
pushd "$DEPLOYDIR/opendata"
|
||||
./gulp
|
||||
rm -rf node_modules
|
||||
popd
|
||||
echo -n "Press [ENTER] to start building the Docker image itself"
|
||||
read dummy
|
||||
docker build . -t $DOCKER_TAG
|
||||
|
||||
echo
|
||||
echo "==================================================================="
|
||||
echo "Deploy of ${PROJECT_NAME} is ready for dockerisation."
|
||||
echo "Docker image of ${PROJECT_NAME} is complete."
|
||||
echo "==================================================================="
|
||||
echo -n "Press [ENTER] to push to Docker Hub"
|
||||
read dummy
|
||||
docker push $DOCKER_TAG
|
||||
|
||||
echo
|
||||
echo "Done"
|
||||
|
||||
84
docker/prep_docker_img.sh
Normal file
84
docker/prep_docker_img.sh
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
DEPLOY_BRANCH=${DEPLOY_BRANCH:-production}
|
||||
DOCKER_TAG="armadillica/blender-mydata"
|
||||
|
||||
# macOS does not support readlink -f, so we use greadlink instead
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
command -v greadlink 2>/dev/null 2>&1 || { echo >&2 "Install greadlink using brew."; exit 1; }
|
||||
readlink='greadlink'
|
||||
else
|
||||
readlink='readlink'
|
||||
fi
|
||||
|
||||
MY_DIR="$(dirname "$($readlink -f "$0")")"
|
||||
cd "$MY_DIR"
|
||||
|
||||
ROOT="$(dirname "$MY_DIR")"
|
||||
DEPLOYDIR="$ROOT/docker/deploy"
|
||||
PROJECT_NAME="mydata"
|
||||
|
||||
if [ -e "$DEPLOYDIR" ]; then
|
||||
echo "$DEPLOYDIR already exists, press [ENTER] to DESTROY AND COPY, Ctrl+C to abort."
|
||||
read dummy
|
||||
rm -rf "$DEPLOYDIR"
|
||||
else
|
||||
echo -n "Deploying to $DEPLOYDIR… "
|
||||
echo "press [ENTER] to continue, Ctrl+C to abort."
|
||||
read dummy
|
||||
fi
|
||||
|
||||
mkdir -p $DEPLOYDIR
|
||||
REMOTE_ROOT="$DEPLOYDIR/$PROJECT_NAME"
|
||||
|
||||
# Check that production branch has been pushed.
|
||||
if [ -n "$(git log origin/$DEPLOY_BRANCH..$DEPLOY_BRANCH --oneline)" ]; then
|
||||
echo "WARNING: not all changes to the $DEPLOY_BRANCH branch have been pushed."
|
||||
echo "Press [ENTER] to continue deploying current origin/$DEPLOY_BRANCH, CTRL+C to abort."
|
||||
read dummy
|
||||
fi
|
||||
|
||||
function git_clone() {
|
||||
REPO_NAME="$1"
|
||||
URL="$2"
|
||||
BRANCH="$DEPLOY_BRANCH"
|
||||
|
||||
set -e
|
||||
echo "==================================================================="
|
||||
echo "CLONING REPO ON $REPO_NAME @$BRANCH"
|
||||
git -C "$DEPLOYDIR" clone --depth 1 --branch $BRANCH $URL $REPO_NAME
|
||||
git -C "$DEPLOYDIR/$REPO_NAME" submodule init
|
||||
git -C "$DEPLOYDIR/$REPO_NAME" submodule update --recommend-shallow
|
||||
|
||||
# We need *some* settings to be able to run `manage.py collectstatic` later.
|
||||
# That command is given while building the docker image.
|
||||
cp "$MY_DIR/deploytime-settings-$REPO_NAME.py" $DEPLOYDIR/$REPO_NAME/$REPO_NAME/settings.py
|
||||
}
|
||||
|
||||
git_clone mydata git@gitlab.com:armadillica/blender-my-data.git
|
||||
git_clone opendata git@gitlab.com:armadillica/blender-open-data.git
|
||||
|
||||
# Gulp everywhere
|
||||
|
||||
# TODO: reinstate this, because it's much faster:
|
||||
# GULP=$ROOT/node_modules/.bin/gulp
|
||||
# if [ ! -e $GULP -o gulpfile.js -nt $GULP ]; then
|
||||
# npm install
|
||||
# touch $GULP # installer doesn't always touch this after a build, so we do.
|
||||
# fi
|
||||
# $GULP --cwd $DEPLOYDIR/mydata --production
|
||||
# $GULP --cwd $DEPLOYDIR/opendata --production
|
||||
|
||||
pushd "$DEPLOYDIR/mydata"
|
||||
./gulp
|
||||
rm -rf node_modules
|
||||
popd
|
||||
pushd "$DEPLOYDIR/opendata"
|
||||
./gulp
|
||||
rm -rf node_modules
|
||||
popd
|
||||
|
||||
echo
|
||||
echo "==================================================================="
|
||||
echo "Deploy of ${PROJECT_NAME} is ready for dockerisation."
|
||||
echo "==================================================================="
|
||||
Reference in New Issue
Block a user