Skip to content

Commit 21c95e3

Browse files
authored
Merge pull request #54 from abordage/feature/integrate-dk-commands
feat(tools): enhance automated tool installation during setup
2 parents be55439 + 694d3a5 commit 21c95e3

File tree

10 files changed

+151
-134
lines changed

10 files changed

+151
-134
lines changed

Makefile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ endif
1717

1818
# Declare all targets as phony (they don't create files)
1919
.PHONY: help status setup start stop restart reset rebuild update \
20-
dk-install dk-uninstall project dump lint tmp-clean
20+
project dump lint
2121

2222
# Colors for output
2323
RED := \033[0;31m
@@ -97,16 +97,6 @@ rebuild: ## [DEPRECATED] Use 'make update' instead
9797
update: ## Update DockerKit, reinstall dk command, and rebuild containers (with cache)
9898
@tools/update.sh
9999

100-
# =============================================================================
101-
# DK COMMAND MANAGEMENT
102-
# =============================================================================
103-
104-
dk-install: ## Install dk command for quick workspace access from any .localhost project
105-
@tools/dk/manager.sh install
106-
107-
dk-uninstall: ## Remove dk command from system
108-
@tools/dk/manager.sh uninstall
109-
110100
# =============================================================================
111101
# CLEANUP & MAINTENANCE
112102
# =============================================================================

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ DockerKit is a modern development environment enabling you to run, configure, an
4848
### Prerequisites
4949

5050
- **Docker & Docker Compose** for container orchestration
51-
- **[mkcert](https://github.com/FiloSottile/mkcert)** for automatic HTTPS certificate generation (recommended)
51+
- **[Homebrew](https://brew.sh)** (macOS only) - required for automatic mkcert installation
5252

5353
### Installation
5454

@@ -62,13 +62,19 @@ cd dockerkit
6262

6363
# 3. Run automatic environment setup
6464
make setup
65+
```
6566

66-
# 4. Start all services
67-
make start
67+
### Automatic Tool Installation
6868

69-
# 5. Install the `dk` command for instant workspace access from any project dir
70-
make dk-install
71-
```
69+
DockerKit automatically installs required development tools during setup:
70+
71+
- **mkcert** - for trusted SSL certificates (installed automatically)
72+
- On macOS: via Homebrew (`brew install mkcert`)
73+
- On Linux/WSL2: from GitHub releases
74+
- Certificate Authority is configured automatically
75+
- **dk command** - for quick workspace access from any project directory
76+
77+
No manual installation required - everything is handled by `make setup`.
7278

7379
### Project Structure
7480

@@ -124,10 +130,6 @@ git clone https://github.com/yourorg/api.git api.localhost
124130
# 2. Reconfigure DockerKit to detect new projects
125131
cd dockerkit
126132
make setup
127-
128-
# 3. Your projects are now available:
129-
# https://myapp.localhost
130-
# https://api.localhost
131133
```
132134

133135
## Configuration
@@ -197,12 +199,8 @@ make status # Show current system status
197199
make project # Create new project (Laravel/Symfony)
198200
make dump # Interactive database backup/restore tool
199201

200-
# Development Tools
201-
make dk-install # Install dk command for quick workspace access
202-
make dk-uninstall # Remove dk command from system
203-
204202
# Maintenance
205-
make update # Update DockerKit, reinstall dk command, and rebuild containers
203+
make update # Update DockerKit and rebuild containers
206204
make reset # Reset project to initial state
207205
make lint # Run all quality checks (Dockerfiles, bash scripts)
208206
make tmp-clean # Clean /tmp inside workspace container

tools/dk/dk.sh

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# =============================================================================
66
# Quick connect to DockerKit workspace container from any .localhost project
77
# Compatible: macOS, Linux, WSL2
8-
# Usage: dk [--help|--version]
8+
# Usage: dk [--help]
99
# =============================================================================
1010

1111
set -euo pipefail
@@ -14,7 +14,6 @@ set -euo pipefail
1414
# SCRIPT METADATA
1515
# =============================================================================
1616

17-
readonly DK_VERSION="1.5.1"
1817

1918
# Update check constants
2019
readonly LAST_CHECK_FILE="$HOME/.dockerkit/last-update-check"
@@ -201,7 +200,7 @@ perform_daily_update_check() {
201200
# Show help message
202201
show_help() {
203202
cat << EOF
204-
DockerKit Quick Connect v${DK_VERSION}
203+
DockerKit Quick Connect
205204
206205
USAGE:
207206
dk [OPTIONS]
@@ -212,20 +211,18 @@ DESCRIPTION:
212211
213212
OPTIONS:
214213
--help Show this help message
215-
--version Show version information
216214
217215
EXAMPLES:
218216
dk # Connect to workspace or show available options
219-
dk --version # Show version number
220217
221218
REQUIREMENTS:
222219
• Must be run from a .localhost project directory
223220
• At least one DockerKit instance must be available
224221
• Docker and docker compose must be installed
225222
226223
INSTALLATION:
227-
Install: make dk-install (from DockerKit directory)
228-
Uninstall: make dk-uninstall (from DockerKit directory)
224+
dk command is automatically installed during 'make setup'
225+
and removed during 'make reset' from DockerKit directory.
229226
Compatible: macOS, Linux, WSL2
230227
231228
MORE INFO:
@@ -235,13 +232,6 @@ MORE INFO:
235232
EOF
236233
}
237234

238-
# Show version information
239-
show_version() {
240-
echo "${DK_VERSION}"
241-
}
242-
243-
244-
245235
# Detect current project name from directory
246236
detect_current_project() {
247237
local current_dir project_name
@@ -365,10 +355,6 @@ parse_arguments() {
365355
show_help
366356
exit "${EXIT_SUCCESS}"
367357
;;
368-
--version|-v)
369-
show_version
370-
exit "${EXIT_SUCCESS}"
371-
;;
372358
-*)
373359
print_error "Unknown option: $1"
374360
show_help

tools/dk/manager.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ dk() {
121121
"\$HOME/.dockerkit/bin/dk" "\$@"
122122
else
123123
echo "dk command not installed."
124-
echo "Run 'make dk-install' in your DockerKit directory."
124+
echo "Run 'make setup' in your DockerKit directory (auto-installs dk)."
125125
return 1
126126
fi
127127
}
@@ -313,7 +313,7 @@ install_dk_command() {
313313
if cp "$DK_SOURCE_SCRIPT" "$DK_INSTALL_PATH"; then
314314
chmod +x "$DK_INSTALL_PATH"
315315
print_success "dk command installed successfully"
316-
print_success "Location: $(purple "$DK_INSTALL_PATH")"
316+
print_success "Location: $(gray "$DK_INSTALL_PATH")"
317317
else
318318
print_error "Failed to install dk command"
319319
return "$EXIT_GENERAL_ERROR"

tools/lib/core/utils.sh

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,6 @@ detect_os() {
6262
esac
6363
}
6464

65-
get_project_version() {
66-
local dk_script_path="$DOCKERKIT_DIR/tools/dk/dk.sh"
67-
68-
if [ -f "$dk_script_path" ]; then
69-
local version
70-
version=$(grep "readonly DK_VERSION=" "$dk_script_path" 2>/dev/null | \
71-
sed 's/.*DK_VERSION="\([^"]*\)".*/\1/' | \
72-
head -n 1)
73-
echo "${version#v}"
74-
else
75-
echo "unknown"
76-
fi
77-
}
78-
7965
command_exists() {
8066
local command_name="$1"
8167

tools/lib/services/packages.sh

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

33
# =============================================================================
4-
# PACKAGE MANAGER
4+
# REQUIRED TOOLS INSTALLER
55
# =============================================================================
6-
# Functions for managing system packages and dependencies
7-
# Usage: source this file and call package management functions
6+
# Functions for installing essential tools required for DockerKit functionality
7+
# Usage: source this file and call install_required_tools()
88
# =============================================================================
99

1010
set -euo pipefail
@@ -20,13 +20,13 @@ PKG_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2020
source "$PKG_SCRIPT_DIR/../core/utils.sh"
2121
source "$PKG_SCRIPT_DIR/../core/config.sh"
2222

23-
check_system_dependencies() {
23+
install_required_tools() {
2424
local os_type
2525
os_type=$(detect_os)
2626

2727
case "$os_type" in
2828
macos|linux|wsl2)
29-
check_required_tools
29+
install_required_dependencies
3030
;;
3131
*)
3232
print_warning "Unsupported operating system: $os_type"
@@ -35,21 +35,21 @@ check_system_dependencies() {
3535
esac
3636
}
3737

38-
check_required_tools() {
38+
install_required_dependencies() {
3939
local required_tools=("mkcert")
4040
local all_ok=true
4141

4242
for tool in "${required_tools[@]}"; do
4343
if ! command_exists "$tool"; then
44-
print_info "$tool: Not found, installing..."
44+
print_info "$tool: not found, installing..."
4545
if ! install_missing_tool "$tool"; then
46-
print_error "$tool: Installation failed"
46+
print_error "$tool: installation failed"
4747
all_ok=false
4848
else
49-
print_success "$tool: Installed successfully"
49+
print_success "$tool: installed successfully"
5050
fi
5151
else
52-
print_success "$tool: Already installed"
52+
print_success "$tool: already installed"
5353
fi
5454
done
5555

@@ -85,7 +85,7 @@ install_mkcert_for_platform() {
8585
install_mkcert_linux
8686
;;
8787
macos)
88-
install_mkcert_macos_stub
88+
install_mkcert_macos
8989
;;
9090
*)
9191
print_error "Unsupported platform for mkcert installation: $os_type"
@@ -136,18 +136,54 @@ install_mkcert_linux() {
136136
return "$EXIT_GENERAL_ERROR"
137137
fi
138138

139+
# Initialize CA after fresh installation
140+
print_info "Setting up local Certificate Authority..."
141+
if mkcert -install >/dev/null 2>&1; then
142+
print_success "Certificate Authority installed successfully"
143+
elif sudo mkcert -install >/dev/null 2>&1; then
144+
print_success "Certificate Authority installed successfully"
145+
else
146+
print_warning "Certificate Authority setup failed (you may need to run 'mkcert -install' manually)"
147+
fi
148+
139149
# Clean up temporary files
140150
rm -rf "$temp_dir" 2>/dev/null || true
141151

142152
return "$EXIT_SUCCESS"
143153
}
144154

145-
install_mkcert_macos_stub() {
146-
print_warning "Automatic mkcert installation for macOS not implemented yet"
147-
print_tip "Please install mkcert manually:"
148-
print_tip " brew install mkcert"
155+
install_mkcert_macos() {
156+
# Check if Homebrew is installed
157+
if ! command_exists "brew"; then
158+
print_error "mkcert installation requires Homebrew"
159+
print_info "Homebrew is not installed. Please install it first:"
160+
print_tip "Run this command in Terminal:"
161+
print_tip " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
162+
print_tip ""
163+
print_tip "After Homebrew installation, run setup again:"
164+
print_tip " make setup"
165+
166+
return "$EXIT_MISSING_DEPENDENCY"
167+
fi
149168

150-
return "$EXIT_MISSING_DEPENDENCY"
169+
# Homebrew is available, check if mkcert is already installed
170+
if command_exists "mkcert"; then
171+
return "$EXIT_SUCCESS"
172+
fi
173+
174+
# Install mkcert via Homebrew (suppress verbose output)
175+
if brew install --quiet mkcert >/dev/null 2>&1; then
176+
# Initialize CA after fresh installation
177+
print_info "Setting up local Certificate Authority..."
178+
if mkcert -install >/dev/null 2>&1; then
179+
print_success "Certificate Authority installed successfully"
180+
else
181+
print_warning "Certificate Authority setup failed (you may need to run 'mkcert -install' manually)"
182+
fi
183+
return "$EXIT_SUCCESS"
184+
else
185+
return "$EXIT_GENERAL_ERROR"
186+
fi
151187
}
152188

153189
check_sudo_access() {

0 commit comments

Comments
 (0)