fix: address code review findings
- Create README.md with project overview, quick start, Docker deployment, CI/CD info - Update CLAUDE.md with Deployment section - Fix cmd/api/main.go to use REDIS_ADDR env var with fallback - Fix Dockerfile to use golang:1.22-alpine instead of golang:1.26-alpine - Fix .gitea/workflows/deploy.yml to include Docker registry prefix in image tags
This commit is contained in:
@@ -47,5 +47,5 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
latest
|
${{ secrets.DOCKER_USERNAME }}/trip-planner:latest
|
||||||
${{ github.sha }}
|
${{ secrets.DOCKER_USERNAME }}/trip-planner:${{ github.sha }}
|
||||||
|
|||||||
29
CLAUDE.md
29
CLAUDE.md
@@ -76,6 +76,35 @@ go fmt ./...
|
|||||||
go vet ./...
|
go vet ./...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
### Docker Deployment
|
||||||
|
|
||||||
|
The project uses a multi-stage Dockerfile:
|
||||||
|
- **Builder stage**: `golang:1.22-alpine` to build `api` and `cron` binaries
|
||||||
|
- **Runtime stage**: `alpine:latest` with minimal footprint (~27MB)
|
||||||
|
|
||||||
|
### Docker Compose
|
||||||
|
|
||||||
|
The `docker-compose.yml` includes:
|
||||||
|
- `api` service: Go HTTP server on port 8080
|
||||||
|
- `cron` service: Go cron binary for reference data updates and station status detection
|
||||||
|
- `postgres`: PostgreSQL 15-alpine with `postgres_data` volume
|
||||||
|
- `redis`: Redis 7-alpine with `redis_data` volume
|
||||||
|
- `watchtower`: nickfedor/watchtower for automatic container updates (interval: 60s)
|
||||||
|
|
||||||
|
### CI/CD Pipeline
|
||||||
|
|
||||||
|
Gitea Actions workflow (`.gitea/workflows/deploy.yml`) provides:
|
||||||
|
- Checkout code
|
||||||
|
- Setup Go 1.22+
|
||||||
|
- Go modules cache
|
||||||
|
- Lint with golangci-lint v1.54.2
|
||||||
|
- Run tests with race detector: `go test -v -race ./...`
|
||||||
|
- Docker Buildx setup
|
||||||
|
- Docker login to registry
|
||||||
|
- Build and push Docker image with tags: `latest` and commit SHA
|
||||||
|
|
||||||
### API Endpoints (from specification)
|
### API Endpoints (from specification)
|
||||||
|
|
||||||
- `GET /v1/cities?query=` — City autocomplete
|
- `GET /v1/cities?query=` — City autocomplete
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Builder stage
|
# Builder stage
|
||||||
FROM golang:1.26-alpine AS builder
|
FROM golang:1.22-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,12 @@ func main() {
|
|||||||
|
|
||||||
// initRedis initializes a Redis client connection.
|
// initRedis initializes a Redis client connection.
|
||||||
func initRedis() *redis.Client {
|
func initRedis() *redis.Client {
|
||||||
|
redisAddr := os.Getenv("REDIS_ADDR")
|
||||||
|
if redisAddr == "" {
|
||||||
|
redisAddr = "localhost:6379"
|
||||||
|
}
|
||||||
rdb := redis.NewClient(&redis.Options{
|
rdb := redis.NewClient(&redis.Options{
|
||||||
Addr: "localhost:6379",
|
Addr: redisAddr,
|
||||||
Password: "",
|
Password: "",
|
||||||
DB: 0,
|
DB: 0,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user