This repository contains a Docker setup for my customizable development environment.
- Debian-based environment with:
- Build-essential
- Java (default-jdk)
- PHP
- Node.js and npm
- MySQL client
- Git, Vim, Curl, Wget, Unzip
- Zsh
-
Build and start the environment:
docker-compose up --build -d
-
Access the container shell:
docker-compose exec dev-env zsh
-
Mount your host project directory (default:
./projects
) to/home/devuser/projects
in the container.- The mount path is now
/home/devuser/projects
, not/workingdir
.
- The mount path is now
-
Build and start the environment:
make up
-
Stop and remove containers:
make down
-
Access the container shell:
make exec
-
View container logs:
make logs
-
View available commands
make help
Create a .env
file in the root directory and set the following environment variables(change accordingly):
# MySQL Configuration
MYSQL_PORT=3307 # Port exposed to the host for MySQL (mapped from 3306 in the container)
MYSQL_ROOT_PASSWORD=root # MySQL root password for the database
MYSQL_DATABASE=dev_database # Default database to create in MySQL
MYSQL_USER=devuser # Non-root database user
MYSQL_PASSWORD=devpassword # Password for the non-root user
# Application Configuration
APP_PORT=8080 # Application port exposed to the host
#Default path
PROJECT_DIR=./projects
MYSQL_DATA=mysql-data
# Host User/Group IDs (for correct file permissions)
USER_ID=1000
GROUP_ID=100
- dev-env: The main development environment.
- mysql: MySQL database service.
${PROJECT_DIR:-./projects}:/home/devuser/projects
: Mounts your project directory to the container.mysql-data:/var/lib/mysql
: Persists the MySQL database data.
dev-network
: Custom isolated network for all services.
- The container’s entrypoint script ensures
/home/devuser/projects
is owned by the correct user/group matching your host (usingUSER_ID
,GROUP_ID
). - This ensures files created in the container remain editable on your host.
- dev-env: Checks the application URL or command.
- mysql: Pings the MySQL service.
- Both
dev-env
andmysql
services will restart unless stopped manually.