Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Last active April 10, 2019 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RichardBronosky/02ed8ad16c48bb5d2ea4b84f2a285ea2 to your computer and use it in GitHub Desktop.
Save RichardBronosky/02ed8ad16c48bb5d2ea4b84f2a285ea2 to your computer and use it in GitHub Desktop.
My basic "build docker image from any directory" script. I have retyped this basic build script so many times that I basically didn't need to create this gist. Until I go a few weeks without doing Docker.
#!/bin/bash -eux
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$script_dir"
docker build -t $(basename $PWD) .
#!/bin/bash -eux
# Put common options here
docker_run_options="--volume $PWD/.npm:/root/.npm -p 8000:8000 --memory 4096m"
# Use env var DOCKER_RUN_OPTIONS to overwrite ^^them^^ at invocation time
docker_run_options="${DOCKER_RUN_OPTIONS:-$docker_run_options}"
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly image_name="$(basename $script_dir)"
# Generic run command
docker run -it --rm --name rtg --workdir /usr/src/app --volume $PWD:/usr/src/app $docker_run_options $image_name bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment