Skip to content

Instantly share code, notes, and snippets.

@matthewstokeley
Last active March 1, 2020 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewstokeley/c23ccc28b50bfecb4e7e66f4f6e9a9b8 to your computer and use it in GitHub Desktop.
Save matthewstokeley/c23ccc28b50bfecb4e7e66f4f6e9a9b8 to your computer and use it in GitHub Desktop.
containerized node development for express jade
#! /usr/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Containerized Express/Jade Development Environment
#
# This file implements a configuration workflow that allows for
# .env population and versioning of a composition file by
# ignoring the secrets file and separating the pre-populated composition file
# into a repo outside of the development environment.
#
# @version 0.0.3
CONFIG=secret.env
COMPOSE=docker-compose.yml
DEST=./../container
## Docker-Compose Aliases
if [ ! .aliases -e ]
then
touch .aliases
fi
echo "alias dcc='docker-compose'" >> .aliases
source .aliases
## @todo diff the COMPOSE file
## Fetch generic docker composition file
if [ ! $COMPOSE -e ]
then
touch $COMPOSE
fi
curl https://gist.githubusercontent.com/matthewstokeley/e14ac60807bd196690b7e1c24a6444e5/raw/47e2077f6e181c82dd9d64dcb0c37c61ffe95aac/docker-compose.yml > docker-compose.yml
touch .gitignore && echo "$CONFIG" >> .gitignore
## Version the composition file
git init && git checkout -b "feature/docker-configuration" && git add -A && git commit -m "add the docker configuration file"
## Move out of the config repo and into the development environment
cp $COMPOSE $DEST
## Create or use an environment variable configuration file
if [ $CONFIG -e ]
then
touch $CONFIG
echo "MYSQL_ROOT_PASSWORD: MYSQL_ROOT" >> $CONFIG
echo "MYSQL_DATABASE: ******" >> $CONFIG
echo "MYSQL_USER: ******" >> $CONFIG
echo "MYSQL_PASSWORD: ******" >> $CONFIG
echo "LOCAL_THEME_PATH: ./" >> $CONFIG
fi
## Populate the docker config file
## @todo review
sed /awk '{print $1}' $CONFIG/awk '{print $2}' $CONFIG/ $COMPOSE > $COMPOSE
# move the bootloading script into the shared valume and install dependencies
cd $DEST && npm init -y && npm install express jade jest jasmine mocha chai winston --save
# scripts object setup
## Boot Services
dcc up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment