Skip to content

Commit ab56ff0

Browse files
committed
Fix Docker buildx compatibility and secure database credentials
- Remove hardcoded credentials from docker-compose.yml - Use environment variables from .env file for database config - Add DOCKER_BUILDKIT=0 to Mage docker commands for buildx compatibility - Update documentation with legacy builder workarounds - Fix Caddyfile access_log directive error
1 parent 7054a27 commit ab56ff0

File tree

12 files changed

+52
-29
lines changed

12 files changed

+52
-29
lines changed

Caddyfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ localhost, localhost:80, localhost:443 {
3333
format console
3434
level INFO
3535
}
36-
37-
# Access logging
38-
access_log stdout {
39-
format console
40-
}
4136
}
4237

4338
# Production domain configuration (uncomment and configure for production)

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ docker compose up --build
9191

9292
**Requirements:** Docker and Docker Compose
9393

94+
> **Note:** This project uses the legacy Docker builder (`DOCKER_BUILDKIT=0`) for maximum compatibility. The Mage commands handle this automatically.
95+
9496
### Local Development
9597

9698
```bash
@@ -173,6 +175,18 @@ mage dockerReset # Reset Docker environment (remove volumes)
173175
mage dockerLogs # Show logs from all Docker services
174176
```
175177

178+
**Docker Build Issues:**
179+
180+
If you encounter buildx plugin errors, the Mage commands automatically use the legacy builder. For manual commands:
181+
182+
```bash
183+
# Use legacy builder for compatibility
184+
DOCKER_BUILDKIT=0 docker compose up --build
185+
186+
# Or use the Mage command (handles this automatically)
187+
mage docker
188+
```
189+
176190
**Quality & Production:**
177191

178192
```bash

docker-compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
LOG_LEVEL: debug
2222

2323
# Development database connection
24-
DATABASE_URL: postgres://user:password@postgres:5432/gowebserver?sslmode=disable
24+
DATABASE_URL: postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@postgres:5432/gowebserver?sslmode=disable
2525

2626
# Enable development features
2727
FEATURES_ENABLE_METRICS: "true"

docs/deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ scp bin/server user@server:/opt/app/
1111

1212
# Set environment and run
1313
export APP_ENVIRONMENT=production
14-
export DATABASE_URL=postgres://user:password@localhost:5432/gowebserver?sslmode=disable
14+
export DATABASE_URL=postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@localhost:5432/gowebserver?sslmode=disable
1515
/opt/app/server
1616
```
1717

docs/docker.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ cd go-web-server
2121
cp .env.example .env
2222
# Edit .env with your database credentials (DATABASE_USER, DATABASE_PASSWORD, etc.)
2323

24-
# Start all services
25-
docker compose up --build
24+
# Start all services (uses legacy builder for compatibility)
25+
DOCKER_BUILDKIT=0 docker compose up --build
2626

2727
# Access application
2828
open http://localhost # Via Caddy reverse proxy
@@ -243,6 +243,16 @@ docker compose logs postgres
243243
docker exec -it gowebserver-postgres psql -U user -d gowebserver -c "SELECT 1;"
244244
```
245245

246+
**Docker buildx issues:**
247+
248+
```bash
249+
# If you see "fork/exec docker-buildx" errors, use legacy builder
250+
DOCKER_BUILDKIT=0 docker compose up --build
251+
252+
# Or use Mage commands (handles this automatically)
253+
mage docker
254+
```
255+
246256
### Performance Optimization
247257

248258
**Database tuning in docker-compose.yml:**

docs/security.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ PostgreSQL connection security:
180180

181181
```bash
182182
# Secure connection strings
183-
DATABASE_URL="postgres://user:password@localhost:5432/gowebserver?sslmode=require"
183+
DATABASE_URL="postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@localhost:5432/gowebserver?sslmode=require"
184184

185185
# Connection pooling limits
186186
DATABASE_MAX_CONNECTIONS=25

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func getDefaults() Config {
146146
RunMigrations bool `koanf:"run_migrations"`
147147
SSLMode string `koanf:"ssl_mode"`
148148
}{
149-
URL: "postgres://user:password@localhost:5432/gowebserver?sslmode=disable",
149+
URL: "postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@localhost:5432/gowebserver?sslmode=disable",
150150
MaxConnections: 25,
151151
MinConnections: 5,
152152
Timeout: 30 * time.Second,

internal/view/home_templ.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/view/layout/base_templ.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/view/users_templ.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)