My collection of dockerfiles to dockerize my development enviroment.
devenv:base
bookworm-slm minimal installation, includes:- oh-my-zsh with agnoster theme
- devuser user
- my gitconfig
- a few gitignore files
devenv:nodejs
installed nodejs on top ofdevenv:base
devenv:ruby
installed rbenv on top ofdevenv:base
devenv:sdman
installed sdkman on top ofdevenv:base
-
First create
devenv:base
imagecd DevEnvBase docker build -t devenv:base .
-
Create others image
-
devenv:nodejs
imagecd DevEnv-Nodejs docker build -t devenv:nodejs .
-
devenv:ruby
imagecd DevEnv-Ruby # create image docker build -t devenv:ruby . # run container docker run -it devenv:ruby --name ruby ## (while on container) install rbenv install 3.2.2 rbenv global 3.2.2 gem install rails
on another terminal, update devenv:ruby running
docker commit
docker commit ruby devenv:ruby
After the commit, devenv:ruby image includes ruby 3.2.2 and rails.
-
devenv:sdkman
imagecd DevEnv-Java docker build -t devenv:base .
-
-
create a docker network
docker network create myappnet
-
create a volume to use with java/sdkman container
docker volume create java-sdkman-vol
-
Run some database container within network
docker run --name pgsqldev -v ${pwd}/data:/var/lib/postgresql/data --env-file .env -dp 5433:5433 --net myappnet --ip 172.18.0.12 postgres:14.2-alpine
docker run --name mongodb -v ${pwd}/data:/data/db --env-file .env -dp 27017:27017 --net myappnet --ip 172.18.0.11 mongo:latest
docker run --name mysqldev -v ${PWD}/data:/var/lib/mysql --env-file .env -dp 3306:3306 --net myappnet --ip 172.18.0.10 mysql:debian
-
Run my project container within network
!!!info move to the folder thats is going to bind to container before run it (ie: project folder
cd ~/Dev/nodejs.proj/
)-
Java project
!!!Warning I binded a volume to the .sdkman folder to avoid install java, maven, etc every time I run the container
# run container docker run --name java --rm -it \ --mount type=bind,source="$(pwd)",target=/home/devuser/development \ --mount source=java-sdkman-vol,target=/home/devuser/.sdkman --net myappnet --ip 172.18.0.4 --publish 8080:8080 \ devenv:sdkman
-
Node project
# run container docker run --name some-app-project --rm -it \ --mount type=bind,source="$(pwd)",target=/home/devuser/development \ --net myappnet --ip 172.18.0.1 --publish 3000:3000 \ devenv:nodejs
-
React project
# run container docker run --name some-app-project --rm -it \ --mount type=bind,source="$(pwd)",target=/home/devuser/development \ --net myappnet --ip 172.18.0.2 --publish 3000:3000 \ devenv:nodejs
-
Ruby project
# run container docker run --name some-app-project --rm -it \ --mount type=bind,source="$(pwd)",target=/home/devuser/development \ --net myappnet --ip 172.18.0.3 --publish 3000:3000 \ devenv:ruby
-
-
And to avoid write down those commands every time, I created a few Terminal profiles