Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Git history
.git/
.gitignore

# Compiled binaries
api-server
ui-server
project-server
org-server
app

# Go module cache and vendor
vendor/

# Test suite (separate module, not needed in app images)
test-suite/

# Documentation and specs
*.md
copilot/
specs/

# Data files
pricing.csv

# OS artifacts
.DS_Store
*.swp
*.swo

# IDE
.vscode/
.idea/

# Temporary and log files
*.log
tmp/
2 changes: 1 addition & 1 deletion .github/workflows/sast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.24
go-version: '1.26'

- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile

# Stage 1: Build the Golang binary
FROM golang:1.24-alpine AS builder
FROM golang:1.26-alpine AS builder

WORKDIR /app

Expand All @@ -12,7 +12,7 @@ RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app ./
RUN CGO_ENABLED=0 GOOS=linux go build -o app ./

FROM alpine:latest

Expand Down
20 changes: 8 additions & 12 deletions Dockerfile.api
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
# syntax=docker/dockerfile:1
# Dockerfile.api - API Server (Port 8080)

# Stage 1: Build the Golang binary
FROM golang:1.24-alpine AS builder
FROM golang:1.26-alpine AS builder

WORKDIR /app

# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download

# Copy source code
COPY . .

# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o api-server -ldflags="-X main.ServerMode=API" ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -o api-server -ldflags="-X main.ServerMode=API" ./

# Stage 2: Create minimal runtime image
# Stage 2: Minimal runtime image
FROM alpine:latest

WORKDIR /app

# Install ca-certificates for HTTPS
RUN apk --no-cache add ca-certificates

# Copy binary and required files
COPY --from=builder /app/api-server .
COPY --from=builder /app/.env ./.env
COPY --from=builder /app/docs /app/docs
COPY --from=builder /app/permissions /app/permissions

# Expose API server port
EXPOSE 8080

# Run API server
CMD ["./api-server"]
30 changes: 30 additions & 0 deletions Dockerfile.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# syntax=docker/dockerfile:1
# Dockerfile.org - Org Server (Port 8083)

FROM golang:1.26-alpine AS builder

WORKDIR /app

COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download

COPY . .

RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -o org-server -ldflags="-X main.ServerMode=Org" ./

FROM alpine:latest

WORKDIR /app

RUN apk --no-cache add ca-certificates

COPY --from=builder /app/org-server .
COPY --from=builder /app/.env ./.env
COPY --from=builder /app/docs /app/docs
COPY --from=builder /app/permissions /app/permissions

EXPOSE 8083
CMD ["./org-server"]
30 changes: 30 additions & 0 deletions Dockerfile.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# syntax=docker/dockerfile:1
# Dockerfile.project - Project Server (Port 8082)

FROM golang:1.26-alpine AS builder

WORKDIR /app

COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download

COPY . .

RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -o project-server -ldflags="-X main.ServerMode=Project" ./

FROM alpine:latest

WORKDIR /app

RUN apk --no-cache add ca-certificates

COPY --from=builder /app/project-server .
COPY --from=builder /app/.env ./.env
COPY --from=builder /app/docs /app/docs
COPY --from=builder /app/permissions /app/permissions

EXPOSE 8082
CMD ["./project-server"]
23 changes: 9 additions & 14 deletions Dockerfile.ui
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
# Dockerfile.ui - UI/Tenant Server (Port 8081)
# syntax=docker/dockerfile:1
# Dockerfile.ui - UI Server (Port 8081)

# Stage 1: Build the Golang binary
FROM golang:1.24-alpine AS builder
FROM golang:1.26-alpine AS builder

WORKDIR /app

# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download

# Copy source code
COPY . .

# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ui-server -ldflags="-X main.ServerMode=UI" ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -o ui-server -ldflags="-X main.ServerMode=UI" ./

# Stage 2: Create minimal runtime image
FROM alpine:latest

WORKDIR /app

# Install ca-certificates for HTTPS
RUN apk --no-cache add ca-certificates

# Copy binary and required files
COPY --from=builder /app/ui-server .
COPY --from=builder /app/.env ./.env
COPY --from=builder /app/docs /app/docs
COPY --from=builder /app/permissions /app/permissions

# Expose UI server port
EXPOSE 8081

# Run UI server
CMD ["./ui-server"]
52 changes: 42 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# Makefile

.PHONY: help

# Project name drives the docker-compose network prefix (defaults to directory name)
COMPOSE_PROJECT_NAME ?= $(notdir $(CURDIR))
MIGRATE_NETWORK := $(COMPOSE_PROJECT_NAME)_auth-network
MIGRATIONS_DIR := $(shell pwd)/db/migrations/sql
DB_MIGRATE_URL := cockroachdb://root@auth-database:26257/defaultdb?sslmode=disable

# Force BuildKit and serialize builds to avoid OOM on low-RAM machines
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1

help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-25s %s\n", $$1, $$2}'

## Development Commands

compose-build: ## Build Docker images
docker-compose build
docker compose build

compose-with-debug: compose-build ## Start with debug logs
@echo "Starting in the debug mode for container"
@docker compose up
@docker compose up

compose-without-app: compose-build ## Start without app container
@echo "Starting in the debug mode for container"
Expand All @@ -28,10 +39,31 @@ compose-stop: ## Stop all containers
@docker compose down

compose-clean: compose-stop ## Stop and remove containers
docker-compose rm -f
docker compose rm -f

compose-build-no-cache: ## Build without cache
docker-compose build --no-cache
docker compose build --no-cache

compose-migrate-debug: compose-build ## Build, run SQL migrations against DB, then start all services with debug logs
@echo "Tearing down any existing containers and volumes for a clean state..."
@docker compose down -v 2>/dev/null || true
@echo "Starting infrastructure (db, redis, rabbitmq, mailpit)..."
@docker compose up -d db redis rabbitmq mailpit
@echo "Waiting for database to be healthy..."
@until [ "$$(docker inspect --format='{{.State.Health.Status}}' auth-database 2>/dev/null)" = "healthy" ]; do \
printf '.'; sleep 2; \
done
@echo " Database is healthy."
@echo "Running SQL migrations from $(MIGRATIONS_DIR)..."
docker run --rm \
--network $(MIGRATE_NETWORK) \
-v $(MIGRATIONS_DIR):/migrations \
migrate/migrate \
-path=/migrations \
-database "$(DB_MIGRATE_URL)" \
up
@echo "Starting all services in debug mode (logs visible)..."
docker compose up

## Testing Commands

Expand All @@ -45,18 +77,18 @@ test-quick: ## Run tests using existing containers (faster)
@cd test-suite && go test -v -timeout 3m ./...

test-start: ## Start test containers without running tests
@cd test-suite && docker-compose -f test-suite/docker-compose.test.yml up -d
@cd test-suite && docker compose -f test-suite/docker-compose.test.yml up -d

test-stop: ## Stop test containers
@cd test-suite && docker-compose -f test-suite/docker-compose.test.yml down
@cd test-suite && docker compose -f test-suite/docker-compose.test.yml down

test-clean: ## Remove test containers and volumes
@cd test-suite && docker-compose -f test-suite/docker-compose.test.yml down -v
@cd test-suite && docker compose -f test-suite/docker-compose.test.yml down -v

test-logs: ## Show test container logs
@cd test-suite && docker-compose -f test-suite/docker-compose.test.yml logs -f
@cd test-suite && docker compose -f test-suite/docker-compose.test.yml logs -f

test-status: ## Show test container status
@cd test-suite && docker-compose -f test-suite/docker-compose.test.yml ps
@cd test-suite && docker compose -f test-suite/docker-compose.test.yml ps

.DEFAULT_GOAL := help
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
### Feature in the Development
- Add refresh expired token in the cache ( adding the logic for cache )
- Add refresh expired token in the cache ( adding the logic for cache )


go run ./cmd/migrate up

go run ./cmd/migrate down
Loading
Loading