Skip to content

My dockerfiles to dockerize my development enviroment 🐳🐳🐳

Notifications You must be signed in to change notification settings

ecureuill/docker-development-enviroment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

My collection of dockerfiles to dockerize my development enviroment.

  1. devenv:base bookworm-slm minimal installation, includes:
    1. oh-my-zsh with agnoster theme
    2. devuser user
    3. my gitconfig
    4. a few gitignore files
  2. devenv:nodejs installed nodejs on top of devenv:base
  3. devenv:ruby installed rbenv on top of devenv:base
  4. devenv:sdmaninstalled sdkman on top of devenv:base

How to create images

  1. First create devenv:base image

    cd DevEnvBase
    docker build -t devenv:base .
  2. Create others image

    • devenv:nodejs image

      cd DevEnv-Nodejs
      docker build -t devenv:nodejs .
    • devenv:ruby image

      cd 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 image

      cd DevEnv-Java
      docker build -t devenv:base .

How I run my containers

  1. create a docker network

    docker network create myappnet
  2. create a volume to use with java/sdkman container

    docker volume create java-sdkman-vol
  3. 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
  4. 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
  5. And to avoid write down those commands every time, I created a few Terminal profiles

    image

About

My dockerfiles to dockerize my development enviroment 🐳🐳🐳

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages