-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile.prod.mk
More file actions
72 lines (61 loc) · 3 KB
/
Copy pathMakefile.prod.mk
File metadata and controls
72 lines (61 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# ============================================================================
# Makefile.prod.mk - Production Deployment
# ============================================================================
# Production commands: Docker image builds, registry push, deployment
# All commands are database-agnostic and respect .promenade.workspace
# ============================================================================
.PHONY: prod docker-build docker-push docker-run swagger-generate swagger-all
# ============================================================================
# Production Runner
# ============================================================================
prod: validate-env ## Run production server (requires ENVIRONMENT=production)
@if [ "$(ENVIRONMENT)" != "production" ]; then \
echo " Error: 'make prod' requires ENVIRONMENT=production"; \
echo " Current: $(ENVIRONMENT)"; \
echo ""; \
echo " Switch to production:"; \
echo " make switch-$(DATABASE_DRIVER)-prod"; \
exit 1; \
fi
@echo " Starting PRODUCTION server ($(DATABASE_DRIVER))..."
@echo " Make sure you know what you're doing!"
@$(MAKE) docker-up
@$(MAKE) migrate
@$(MAKE) run
# ============================================================================
# Docker Production
# ============================================================================
docker-build: validate-env ## Build production Docker image (uses DATABASE_DRIVER from workspace)
@echo "Building production Docker image ($(DATABASE_DRIVER))..."
docker build -t $(APP_NAME):$(VERSION) -f docker/Dockerfile .
docker tag $(APP_NAME):$(VERSION) $(APP_NAME):latest
@echo " Built: $(APP_NAME):$(VERSION)"
@echo " Tagged: $(APP_NAME):latest"
docker-push: ## Push Docker image to registry (requires DOCKER_REGISTRY)
@if [ -z "$(DOCKER_REGISTRY)" ]; then \
echo " Error: DOCKER_REGISTRY not set"; \
echo "Usage: make docker-push DOCKER_REGISTRY=your-registry.com"; \
exit 1; \
fi
@echo "Pushing to $(DOCKER_REGISTRY)..."
docker tag $(APP_NAME):$(VERSION) $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)
docker tag $(APP_NAME):$(VERSION) $(DOCKER_REGISTRY)/$(APP_NAME):latest
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)
docker push $(DOCKER_REGISTRY)/$(APP_NAME):latest
@echo " Pushed to registry"
docker-run: validate-env ## Run production Docker container (uses workspace configuration)
@echo "Running production container ($(DATABASE_DRIVER) / $(ENVIRONMENT))..."
docker run --rm \
-e DATABASE_DRIVER=$(DATABASE_DRIVER) \
-e ENVIRONMENT=$(ENVIRONMENT) \
-p 8081:8081 \
$(APP_NAME):$(VERSION)
# ============================================================================
# API Documentation (Swagger)
# ============================================================================
swagger-generate: ## Generate Swagger documentation
@echo "Generating Swagger docs..."
swag init -g cmd/api/main.go -o docs/swagger
@echo " Swagger docs generated"
swagger-all: swagger-generate ## Generate all API documentation
@echo " All API documentation generated"