Last active
April 10, 2019 12:30
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eux | |
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
cd "$script_dir" | |
docker build -t $(basename $PWD) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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