Skip to content

Commit 5635faf

Browse files
authored
Merge pull request #2 from AlexWaha/add-ssl
Final check, fix, done
2 parents 94a8a22 + 25925e0 commit 5635faf

File tree

6 files changed

+184
-61
lines changed

6 files changed

+184
-61
lines changed

README.md

Lines changed: 158 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# 🚀 DockDev — Instant Docker Dev Domains
22

3-
> ⚡️ DockDev is a fast CLI tool that helps you create isolated Docker-based development environments with reverse proxy and custom local domains.
4-
>
5-
> It lets you work locally in Windows + WSL with multiple projects — and access them in the browser using friendly domain names like http://app.local.
3+
> ⚡️ DockDev is a fast CLI tool that helps you create isolated Docker-based development environments with reverse proxy and custom local domains.
4+
>
5+
> It lets you work locally in Windows + WSL with multiple projects — and access them in the browser using friendly domain names like https://app.test.
66
77
![Docker](https://img.shields.io/badge/Docker-ready-blue)
88
![Go](https://img.shields.io/badge/Built%20with-Go-informational)
@@ -16,48 +16,67 @@
1616
**DockDev** is a developer CLI utility written in Go that helps you instantly:
1717

1818
✅ Features
19-
- 🔧 Spin up isolated Docker-based dev environments with NGINX and any containers like PHP, Redis etc.
19+
- 🔧 Spin up isolated Docker-based dev environments with NGINX, PHP, Node.js, Redis, ElasticMQ etc.
2020
- 🌐 All traffic is routed through a shared reverse proxy (nginx-reverse-proxy) for seamless local domain support
21+
- 🔐 **Automatic SSL certificate generation** with Windows trust store integration (HTTPS ready!)
2122
- 🛠 Assign static IPs via a shared user-defined Docker network (bridge mode)
22-
- 🌍 Access each project via clean local domains like http://app.local
23+
- 🌍 Access each project via clean local domains like https://app.test
2324
- 🗂 Automatically add the domain to your Windows hosts file
2425
- ⚙️ Reverse proxy configs are generated per-project and hot-reloaded or restarted as needed
25-
- 🗃️ Includes a shared MySQL container for all projects — connect via native MySQL GUI clients on Windows (e.g. TablePlus, DBeaver, DataGrip etc.)
26+
- 🗃️ Includes a shared MySQL container for all projects — connect via native MySQL GUI clients on Windows
27+
- 🖥️ Interactive CLI interface for creating and managing projects
28+
- 🚀 Automatic Docker Desktop startup and container management
2629

2730
✅ Ideal for full-stack development inside **WSL2 + Docker Desktop** environments.
2831

2932
---
3033

34+
## 📋 Prerequisites
35+
36+
- Windows with WSL2
37+
- Docker Desktop
38+
- Go 1.24+ (for building from source)
39+
3140
## 🛠 Installation & Build
3241

33-
💡 You don't need to build it, use the ready-to-run script `dockerdev`
42+
### Option 1: Build from Source 🔨
3443

35-
1. Install [Go](https://go.dev/dl/)
36-
2. Clone the repository and enter the folder:
44+
1. Clone the repository
45+
2. Run the build script:
3746

3847
```bash
39-
git clone https://github.com/your-org/dockdev.git
40-
cd dockdev
48+
./build.bat
4149
```
4250

43-
3. Build the binary (choose based on your OS)::
51+
The build script will:
52+
- Compile the Go code for Linux (WSL compatibility)
53+
- Create a distribution in the `../dist` folder with the executable
4454

45-
🪟 For Windows (CMD):
46-
Run `build.bat`
55+
3. Manually copy the required files to your WSL user folder for example to `/home/user/dockdev`:
56+
- `dist/dockdev` (executable)
57+
- `dist/templates/` (directory with all templates)
58+
- Create a `.env` configuration file (see Configuration section)
59+
60+
4. Set proper executable permissions in your WSL environment:
61+
```bash
62+
chmod +x dockdev
63+
```
4764

48-
> This produces a Linux-compatible binary you can run inside WSL2 or Linux servers.
65+
### Option 2: Use Pre-built Binary 📦
66+
67+
1. Download the latest release from the releases page
68+
2. Extract the archive to your preferred location
69+
3. Run the executable from WSL2
4970

5071
---
5172

5273
## ⚙️ Setup
5374

54-
### Copy required files and folders:
55-
56-
> All from folder dist to your WSL
75+
### Required files and folders in your WSL environment:
5776

58-
- `.env`
59-
- `dockdev`
60-
- `templates`
77+
- `.env` (configuration file)
78+
- `dockdev` (executable)
79+
- `templates/` (directory with templates)
6180

6281
---
6382
## 💡 Before you start!
@@ -67,54 +86,73 @@ Run `build.bat`
6786
> For example: `root /var/www/html/public;`
6887
>
6988
> 1. You can update it before adding new project in `templates/nginx.conf.tmpl` for all projects
70-
>
71-
> 2. or after, directly in `domains/YOUR_DOMAIN/conf/nginx/default.conf`
89+
>
90+
> 2. or after, directly in `domains/YOUR_DOMAIN/conf/nginx/default.conf`
7291
> #### If #2 - Don't forget to remove and run project containers manually!
7392
93+
---
7494

7595
## 🚀 Usage
7696

77-
### ➕ Create a new domain/project
97+
### 📘 Available Commands
98+
99+
| Command | Description |
100+
|---------|-------------|
101+
| `./dockdev` | Start interactive mode |
102+
| `./dockdev domain.test` | Create a new project with the specified domain |
103+
| `./dockdev domain.test --no-ssl` | Create a project without SSL (not recommended) |
104+
| `./dockdev rm domain.test` | Delete an existing project |
105+
| `./dockdev -H` or `--help` | Show help message |
78106

79-
#### Interactive:
107+
### 💬 Interactive Mode
108+
109+
Run the tool without arguments to enter interactive mode:
80110

81111
```bash
82112
./dockdev
83113
```
84114

85-
#### Direct:
115+
Interactive mode will:
116+
- Show existing projects
117+
- Allow you to create new projects
118+
- Allow you to delete existing projects
119+
- Guide you through all options with prompts
120+
121+
### 🆕 Create a New Project
86122

87123
```bash
88-
./dockdev app.local
124+
./dockdev mydomain.test
89125
```
90126

91127
🔧 It will:
92128

93-
- Create `domains/app.local/`
94-
- Assign next free IP like `10.0.100.12`
129+
- Create `domains/mydomain.test/`
130+
- Generate SSL certificates and add them to Windows trust store (**HTTPS ready**)
131+
- Assign next free IP like `172.20.0.12`
95132
- Assign IP's for all project containers
96133
- Generate:
97-
- `docker-compose.yml`
98-
- `conf/nginx/default.conf`
99-
- `app/index.html`
100-
- reverse proxy config in `shared-services/sites`
134+
- `docker-compose.yml`
135+
- `conf/nginx/default.conf`
136+
- `app/index.html`
137+
- reverse proxy config in `shared-services/sites`
101138
- Update:
102-
- `.ipmap.env` > This file just FYI
103-
- `Windows hosts` file
139+
- `.ipmap.env` > This file just FYI
140+
- `Windows hosts` file
141+
- Automatically start all services
142+
- Open your browser to https://mydomain.test
104143

105144
> Your application must be in `app` folder: `domains/YOUR_DOMAIN/app`
106-
---
107145
108-
### 🗑 Remove a project
146+
### 🗑️ Delete a Project
109147

110148
```bash
111-
./dockdev rm app.local
149+
./dockdev rm mydomain.test
112150
```
113151

114152
You'll be prompted:
115153

116154
```
117-
Are you sure you want to delete domain 'app.local'? [y/N]
155+
Are you sure you want to delete domain 'mydomain.test'? [y/N]
118156
```
119157

120158
Deletes:
@@ -123,16 +161,91 @@ Deletes:
123161
- Reverse proxy `.conf`
124162
- IP mapping entry
125163
- Hosts file entry
164+
- SSL certificates from disk and Windows trust store
126165
- Drop all domain containers
127166

167+
### ❓ Show Help
168+
169+
```bash
170+
./dockdev --help
171+
```
172+
173+
---
174+
175+
## 🏗️ Project Structure
176+
177+
Each project environment includes:
178+
179+
- 🌐 Nginx web server
180+
- 🐘 PHP-FPM 8.3
181+
- 📦 Node.js 23
182+
- ⚡ Redis server
183+
- 📨 ElasticMQ (SQS-compatible message queue)
184+
- 🗃️ Shared MySQL database (across all projects)
185+
186+
---
187+
188+
## 🔐 SSL Certificates
189+
190+
DockDev automatically:
191+
192+
1. Generates a root CA certificate and adds it to Windows trust store
193+
2. Creates domain-specific SSL certificates for each project
194+
3. Configures Nginx to use HTTPS
195+
4. Makes all projects accessible via secure HTTPS connections
196+
197+
This means you can develop with:
198+
- HTTPS by default
199+
- No browser security warnings
200+
- Proper SSL testing in your local environment
201+
- Full compatibility with secure-only features
202+
203+
---
204+
205+
## ⚙️ Configuration
206+
207+
The tool uses an `.env` file for configuration:
208+
209+
```
210+
DOCKDEV_FOLDER=dockdev
211+
NETWORK_NAME=local_net
212+
SUBNET=10.0.100.0/24
213+
REVERSE_PROXY_IP=10.0.100.2
214+
SHARED_MYSQL_IP=10.0.100.3
215+
PROJECT_START_IP=10.0.100.10
216+
MYSQL_ROOT_PASSWORD=root
217+
MYSQL_USER=user
218+
MYSQL_PASSWORD=userpass
219+
```
220+
221+
---
222+
223+
## 📁 Directory Structure
224+
225+
```
226+
├── dockdev # Main executable
227+
├── templates/ # Project templates
228+
│ ├── app/ # Default web application files
229+
│ ├── conf/ # Configuration templates
230+
│ ├── image/ # Docker image definitions
231+
│ │ ├── node/ # Node.js image
232+
│ │ └── php/ # PHP image
233+
│ └── shared-services/ # Shared services templates
234+
├── domains/ # Generated project directories
235+
└── shared-services/ # Shared services (MySQL, Nginx proxy)
236+
├── certs/ # SSL certificates
237+
├── sites/ # Nginx site configurations
238+
└── data/ # Persistent data
239+
```
240+
128241
---
129242

130243
## 🧱 Architecture
131244

132245
- 🔧 `dockdev`: CLI manager (Go)
133-
- 📁 `templates/`: reusable template files
246+
- 📁 `templates/`: reusable template files
134247
> You can extend docker-compose.yml.tmpl with your containers
135-
- 🌍 `shared-services/`: reverse proxy & shared Mysql DB
248+
- 🌍 `shared-services/`: reverse proxy & shared MySQL DB
136249
- 🛠 `.ipmap.env`
137250
>📘 Reference file for developers, to track which containers was assigned to which IP
138251
- 🔌 All containers in one shared Docker `bridge` network
@@ -141,8 +254,8 @@ Deletes:
141254

142255
## ✅ Platform Compatibility
143256

144-
| Platform | Supported |
145-
|-----------------------|-----------|
257+
| Platform | Supported |
258+
|-----------------------|----------------|
146259
| ✅ Windows 10/11 + WSL | ✔️ Recommended |
147260

148261
---
@@ -151,6 +264,6 @@ All routed via NGINX with shared IP space and automatic DNS mapping.
151264

152265
---
153266

154-
## 📄 License
267+
## 📝 License
155268

156-
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
269+
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.

dist/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ PROJECT_START_IP=10.0.100.10
1010
# Shared MySQL credentials
1111
MYSQL_ROOT_PASSWORD=root
1212
MYSQL_USER=user
13-
MYSQL_PASSWORD=userpass
13+
MYSQL_PASSWORD=userpass

dist/dockdev

210 KB
Binary file not shown.

dist/templates/shared-services/docker-compose.yml.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
- ./nginx.conf:/etc/nginx/nginx.conf:ro
1010
- ./sites:/etc/nginx/sites:ro
1111
- ./certs:/etc/nginx/ssl:ro
12-
- ./logs/nginx:/var/log/nginx
12+
- ./logs/nginx:/var/log/nginx:rw
1313
networks:
1414
{{.NetworkName}}:
1515
ipv4_address: {{.ReverseProxyIP}}
@@ -24,8 +24,8 @@ services:
2424
MYSQL_USER: {{.MySQLUser}}
2525
MYSQL_PASSWORD: {{.MySQLPassword}}
2626
volumes:
27-
- ./data/mysql:/var/lib/mysql
28-
- ./logs/mysql:/var/log/mysql
27+
- ./data/mysql:/var/lib/mysql:rw
28+
- ./logs/mysql:/var/log/mysql:rw
2929
ports: ['3306:3306']
3030
networks:
3131
{{.NetworkName}}:

dist/templates/site-ssl.conf.tmpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server {
2+
listen 80;
3+
server_name {{.Domain}};
4+
return 301 https://$host$request_uri;
5+
}
6+
7+
server {
8+
listen 443 ssl;
9+
server_name {{.Domain}};
10+
11+
ssl_certificate /etc/nginx/ssl/{{.Domain}}/{{.Domain}}.crt;
12+
ssl_certificate_key /etc/nginx/ssl/{{.Domain}}/{{.Domain}}.key;
13+
ssl_protocols TLSv1.2 TLSv1.3;
14+
ssl_ciphers HIGH:!aNULL:!MD5;
15+
16+
location / {
17+
proxy_pass http://{{.IPsByService.main}}:80;
18+
proxy_set_header Host $host;
19+
proxy_set_header X-Real-IP $remote_addr;
20+
}
21+
}

dist/templates/site.conf.tmpl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
server {
22
listen 80;
33
server_name {{.Domain}};
4-
return 301 https://$host$request_uri;
5-
}
6-
7-
server {
8-
listen 443 ssl;
9-
server_name {{.Domain}};
10-
11-
ssl_certificate /etc/nginx/ssl/{{.Domain}}/{{.Domain}}.crt;
12-
ssl_certificate_key /etc/nginx/ssl/{{.Domain}}/{{.Domain}}.key;
13-
ssl_protocols TLSv1.2 TLSv1.3;
14-
ssl_ciphers HIGH:!aNULL:!MD5;
154

165
location / {
176
proxy_pass http://{{.IPsByService.main}}:80;
187
proxy_set_header Host $host;
198
proxy_set_header X-Real-IP $remote_addr;
209
}
21-
}
10+
}

0 commit comments

Comments
 (0)