Skip to content

Instantly share code, notes, and snippets.

@sergio1990
Created March 15, 2017 14:47
Show Gist options
  • Save sergio1990/f4a6e957ca4e3b73cc355fe9607b70a2 to your computer and use it in GitHub Desktop.
Save sergio1990/f4a6e957ca4e3b73cc355fe9607b70a2 to your computer and use it in GitHub Desktop.
Example of Docker as a Function
function install_mix_dependencies() {
echo "Starting installing MIX dependencies..."
docker run \
--rm --memory="512M" \
-w="/app" \
-v $PWD:/app \
-e MIX_ENV=prod \
--entrypoint=/app/docker/mix_deps_install.sh \
elixir:1.3.2
}
function install_npm_dependencies() {
echo "Starting installing NPM dependencies..."
docker run \
--rm --memory="512M" \
-w="/app" \
-v $PWD:/app \
--entrypoint=/app/docker/npm_deps_install.sh \
node:6.9.4
}
function build_web_container() {
echo "Building web container..."
docker build -t my_app_image .
}
function run_web_container() {
echo "Running web container..."
docker run \
--name $APP_CONTAINER_NAME \
--link $DB_CONTAINER_NAME:db_host \
-d -p 8888:8888 -i my_app_image
}
install_mix_dependencies;
install_npm_dependencies;
build_web_container;
run_web_container;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment