-
Notifications
You must be signed in to change notification settings - Fork 3
chore: infra, compose, makefile and env cleanup #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| VITE_API_URL=http://localhost:8080 | ||
|
|
||
| CLIENT_PORT=8000 | ||
| SERVER_PORT=8080 | ||
|
|
||
| POSTGRES_USER=capuchin_user | ||
| POSTGRES_PASSWORD=capuchin | ||
| POSTGRES_DB=capuchin_dev | ||
| POSTGRES_HOST=capuchin-db | ||
| POSTGRES_PORT=5432 | ||
| # Only needed when running the backend outside Docker (e.g. `go run` or `air` directly). | ||
| # In compose, the host is hardcoded to the postgres container name (capuchin-db). | ||
| # POSTGRES_HOST=localhost | ||
|
|
||
| JWT_SECRET=your_jwt_secret_here | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ dist-ssr/ | |
| # Test binary, built with `go test -c` | ||
| *.test | ||
| server | ||
| test.sh | ||
|
|
||
| # Go workspace file | ||
| go.work | ||
|
|
@@ -97,3 +98,8 @@ crash.*.log | |
| # personal | ||
| docs/ideas.md | ||
| backup/ | ||
| .kiro | ||
|
|
||
|
|
||
| # removing for now | ||
| .github/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .github contains workflow folder, which are our github action files. Why are we ignoring them?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's intentional, I don't want ci pipeline to be triggered yet, once migration implementation is merged then this can be removed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't create the PR then, or use a feature called 'Draft PR' |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,34 +6,56 @@ ifneq (, $(shell command -v docker 2> /dev/null)) | |
| CONTAINER_RUNTIME := docker | ||
| endif | ||
|
|
||
| # Docker Dev Mode (Hot Reload) | ||
| dev: | ||
| .DEFAULT_GOAL := help | ||
|
|
||
| help: ## Show available targets | ||
| @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
|
||
| # ── Dev (hot reload via Docker) ─────────────────────────────────────────────── | ||
|
|
||
| dev: ## Start all services in dev mode (hot reload) | ||
| $(CONTAINER_RUNTIME) compose --env-file .env.example -f compose-dev.yml up --build -d | ||
|
|
||
| dev-logs: | ||
| $(CONTAINER_RUNTIME) compose -f compose-dev.yml logs | ||
| dev-logs: ## Tail dev logs | ||
| $(CONTAINER_RUNTIME) compose -f compose-dev.yml logs -f | ||
|
|
||
| dev-down: | ||
| dev-down: ## Stop dev services | ||
| $(CONTAINER_RUNTIME) compose -f compose-dev.yml down | ||
| clean: | ||
|
|
||
| clean: ## Stop dev services and remove volumes, images, orphans | ||
| $(CONTAINER_RUNTIME) compose -f compose-dev.yml down --volumes --remove-orphans --rmi all | ||
|
|
||
| # ── Prod ────────────────────────────────────────────────────────────────────── | ||
|
|
||
| prod: | ||
| $(CONTAINER_RUNTIME) compose --env-file .env -f compose.yml up | ||
| prod: ## Start all services in prod mode (detached) | ||
| $(CONTAINER_RUNTIME) compose --env-file .env -f compose.yml up -d | ||
|
|
||
| logs: | ||
| logs: ## Tail prod logs | ||
| $(CONTAINER_RUNTIME) compose -f compose.yml logs -f | ||
|
|
||
| down: | ||
| down: ## Stop prod services | ||
| $(CONTAINER_RUNTIME) compose -f compose.yml down | ||
|
|
||
| # ── Local dev (outside Docker) ──────────────────────────────────────────────── | ||
|
|
||
| frontend: | ||
| frontend: ## Start frontend dev server | ||
| cd frontend && npm run dev | ||
|
|
||
| backend: | ||
| backend: ## Start backend with hot reload (requires air: go install github.com/air-verse/air@v1.61.7) | ||
| cd backend && air | ||
|
|
||
| .PHONY: dev dev-logs dev-down prod logs down | ||
| # ── Database ────────────────────────────────────────────────────────────────── | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this |
||
|
|
||
| migrate: ## Run migrations against localhost DB (reads .env for credentials) | ||
| @set -a && . ./.env.example && set +a && export POSTGRES_HOST=localhost && cd backend/migration && go run ./cmd/migrate up | ||
|
|
||
| migrate-down: ## Roll back the last migration against localhost DB | ||
| @set -a && . ./.env.example && set +a && export POSTGRES_HOST=localhost && cd backend/migration && go run ./cmd/migrate down | ||
|
|
||
| seed: ## Seed dev database with sample data (reads .env.example for credentials) | ||
| @set -a && . ./.env.example && set +a && export POSTGRES_HOST=localhost && cd backend && go run ./cmd/seed | ||
|
|
||
| migrate-build: ## Build migration Docker image | ||
| docker build -f backend/migration/Dockerfile -t capuchin-migration ./backend | ||
|
|
||
| .PHONY: help dev dev-logs dev-down clean prod logs down frontend backend migrate migrate-down seed migrate-build | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| vendor | ||
| bin | ||
| server | ||
| tmp | ||
| *.exe | ||
| *.exe~ | ||
| *.dll | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,37 @@ | ||
| FROM golang:1.25.5-alpine AS deps | ||
| FROM golang:1.26-alpine AS deps | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Download dependencies | ||
| COPY go.mod go.sum ./ | ||
| RUN go mod download | ||
|
|
||
| # Build Stage | ||
| FROM deps AS builder | ||
|
|
||
| # Copy source code | ||
| COPY . . | ||
|
|
||
| # Build the application | ||
| # CGO_ENABLED=0 ensures a statically linked binary | ||
| RUN CGO_ENABLED=0 GOOS=linux go build -o server cmd/server/main.go | ||
|
|
||
| # Development Stage | ||
| # Development Stage - pinned air version for reproducible dev builds | ||
| FROM deps AS dev | ||
|
|
||
| RUN go install github.com/air-verse/air@latest | ||
| RUN go install github.com/air-verse/air@v1.61.7 | ||
|
|
||
| CMD ["air", "-c", "air.toml"] | ||
|
|
||
|
|
||
| # Final Stage | ||
| # Final Stage - minimal image, non-root user for security | ||
| FROM scratch | ||
|
|
||
| # Set working directory to the app root | ||
| WORKDIR /app | ||
|
|
||
| # Copy the binary from the builder stage | ||
| # Copy passwd so the non-root user exists in scratch | ||
| COPY --from=builder /etc/passwd /etc/passwd | ||
|
|
||
| COPY --from=builder /app/server ./ | ||
|
|
||
| # Expose the application port | ||
| EXPOSE 8080 | ||
|
|
||
| # Run the application | ||
| CMD ["./server"] | ||
| USER nobody | ||
|
|
||
| CMD ["./server"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not hardcoded, compose is using the network name which is
capuchin-dbelse you won't be able to connect