Skip to content

Commit 22ce012

Browse files
committed
1. Simplified deployment - No Docker dependencies, direct Ubuntu SystemD service
2. Traditional server approach - Perfect for self-hosting behind Caddy with Cloudflare DNS 3. Reduced complexity - Eliminates container orchestration overhead 4. Better performance - Direct binary execution without containerization layer 5. Easier monitoring - Standard systemd service management and journald logging 6. Production ready - Includes security hardening, resource limits, and proper service isolation
1 parent 641cf45 commit 22ce012

File tree

16 files changed

+556
-1445
lines changed

16 files changed

+556
-1445
lines changed

Caddyfile

Lines changed: 0 additions & 134 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 64 deletions
This file was deleted.

README.md

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<p align="center">
66
<a href="https://github.com/dunamismax/go-web-server">
7-
<img src="https://readme-typing-svg.demolab.com/?font=Fira+Code&size=24&pause=1000&color=00ADD8&center=true&vCenter=true&width=900&lines=The+Modern+Go+Stack;Echo+v4+Framework+with+Type-Safe+Templates;HTMX+Dynamic+UX+without+JavaScript;SQLC+Generated+Queries+with+PostgreSQL;CSRF+Protection+and+Input+Sanitization;Structured+Error+Handling+and+Request+Tracing;Hot+Reload+Development+with+Mage+Automation;Single+Binary+Deployment+at+15MB;Production-Ready+Security+Middleware;Docker+First+Deployment" alt="Typing SVG" />
7+
<img src="https://readme-typing-svg.demolab.com/?font=Fira+Code&size=24&pause=1000&color=00ADD8&center=true&vCenter=true&width=900&lines=The+Modern+Go+Stack;Echo+v4+Framework+with+Type-Safe+Templates;HTMX+Dynamic+UX+without+JavaScript;SQLC+Generated+Queries+with+PostgreSQL;CSRF+Protection+and+Input+Sanitization;Structured+Error+Handling+and+Request+Tracing;Hot+Reload+Development+with+Mage+Automation;Single+Binary+Deployment+at+15MB;Production-Ready+Security+Middleware;Ubuntu+SystemD+Deployment" alt="Typing SVG" />
88
</a>
99
</p>
1010

@@ -71,27 +71,36 @@ A production-ready template for modern web applications using **The Modern Go St
7171

7272
## Quick Start
7373

74-
### Docker Deployment (Recommended)
74+
### Ubuntu Production Deployment (Recommended)
7575

7676
```bash
7777
# Clone repository
7878
git clone https://github.com/dunamismax/go-web-server.git
7979
cd go-web-server
8080

81+
# Install PostgreSQL
82+
sudo apt update
83+
sudo apt install postgresql postgresql-contrib
84+
85+
# Create database and user
86+
sudo -u postgres createdb gowebserver
87+
sudo -u postgres createuser -P gowebserver # Set password when prompted
88+
8189
# Create your environment file
8290
cp .env.example .env
8391
# Edit .env with your database credentials (DATABASE_USER, DATABASE_PASSWORD, etc.)
8492

85-
# Start all services (PostgreSQL + App + Caddy)
86-
docker compose up --build
93+
# Install Go dependencies and build
94+
mage setup
95+
mage build
8796

88-
# Access application at http://localhost
89-
# Or direct app access at http://localhost:8080
90-
```
97+
# Run database migrations
98+
mage migrate
9199

92-
**Requirements:** Docker and Docker Compose
100+
# Server binary available at: bin/server
101+
```
93102

94-
> **Note:** This project uses the legacy Docker builder (`DOCKER_BUILDKIT=0`) for maximum compatibility. The Mage commands handle this automatically.
103+
**Requirements:** Ubuntu 20.04+, PostgreSQL, Go 1.24+
95104

96105
### Local Development
97106

@@ -108,8 +117,9 @@ cp .env.example .env
108117
# Install development tools and dependencies
109118
mage setup
110119

111-
# Start PostgreSQL database
112-
docker compose up postgres -d
120+
# Ensure PostgreSQL is running locally
121+
sudo systemctl start postgresql
122+
sudo systemctl enable postgresql
113123

114124
# Start development server with hot reload
115125
mage dev
@@ -121,7 +131,7 @@ mage dev
121131

122132
- Go 1.24+
123133
- Mage build tool (`go install github.com/magefile/mage@latest`)
124-
- Docker (for PostgreSQL database)
134+
- PostgreSQL database (local installation)
125135

126136
**Note:** First run of `mage setup` installs all development tools automatically.
127137

@@ -132,7 +142,6 @@ mage dev
132142
| Guide | Description |
133143
|-------|-------------|
134144
| **[Development Guide](docs/development.md)** | Local setup, hot reload, database management, and daily workflow |
135-
| **[Docker Guide](docs/docker.md)** | Docker deployment, management, and production setup |
136145
| **[API Reference](docs/api.md)** | HTTP endpoints, HTMX integration, and CSRF protection |
137146
| **[Architecture](docs/architecture.md)** | System design, components, and technology decisions |
138147
| **[Security Guide](docs/security.md)** | CSRF, sanitization, headers, rate limiting, and monitoring |
@@ -166,26 +175,6 @@ mage migrateDown # Roll back last migration
166175
mage migrateStatus # Show migration status
167176
```
168177

169-
**Docker:**
170-
171-
```bash
172-
mage docker # Start all services (PostgreSQL + App + Caddy)
173-
mage dockerDown # Stop all Docker services
174-
mage dockerReset # Reset Docker environment (remove volumes)
175-
mage dockerLogs # Show logs from all Docker services
176-
```
177-
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-
```
189178

190179
**Quality & Production:**
191180

@@ -254,17 +243,20 @@ go-web-server/
254243
<img src="https://github.com/dunamismax/images/blob/main/golang/gopher-aviator.jpg" alt="Go Gopher" width="400" />
255244
</p>
256245

257-
## Docker-First Deployment
246+
## Ubuntu SystemD Deployment
258247

259248
```bash
260-
# Production deployment with all services
261-
docker compose up --build
262-
263-
# Or build optimized binary for custom deployment
249+
# Build optimized binary for production deployment
264250
mage build # Creates optimized binary in bin/server (~15MB)
251+
252+
# Create systemd service file
253+
sudo cp scripts/gowebserver.service /etc/systemd/system/
254+
sudo systemctl daemon-reload
255+
sudo systemctl enable gowebserver
256+
sudo systemctl start gowebserver
265257
```
266258

267-
The binary includes embedded Pico.css, HTMX, and Templ templates. **Docker-first architecture** with PostgreSQL, Caddy reverse proxy, and automatic HTTPS. Single binary deployment option available for custom environments.
259+
The binary includes embedded Pico.css, HTMX, and Templ templates. **Single binary deployment** with local PostgreSQL backend. Perfect for traditional Ubuntu servers behind Caddy reverse proxy with Cloudflare DNS.
268260

269261
## Key Features Demonstrated
270262

0 commit comments

Comments
 (0)