build: add dev compose stack, container image and makefile
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
3b3879d9b5
commit
073668a5b4
4 files changed
+88
No files matched your search
@@ -0,0 +1,4 @@
|
||||
UPTIME_DATABASE_URL=postgres://uptime:uptime@localhost:5432/uptime?sslmode=disable
|
||||
UPTIME_REDIS_URL=redis://localhost:6379/0
|
||||
UPTIME_LOG_FORMAT=text
|
||||
UPTIME_CHECKER_REGION=local
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM node:24-alpine AS web
|
||||
WORKDIR /src
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --no-audit --no-fund
|
||||
COPY internal/web ./internal/web
|
||||
RUN npm run build
|
||||
|
||||
FROM golang:1.27-alpine AS build
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
COPY --from=web /src/internal/web/static/dist ./internal/web/static/dist
|
||||
ARG VERSION=dev
|
||||
ARG COMMIT=none
|
||||
RUN CGO_ENABLED=0 go build -trimpath \
|
||||
-ldflags "-s -w -X git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo.Version=${VERSION} -X git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo.Commit=${COMMIT}" \
|
||||
-o /out/ ./cmd/...
|
||||
|
||||
FROM gcr.io/distroless/static-debian12:nonroot
|
||||
COPY --from=build /out/ /usr/local/bin/
|
||||
USER nonroot
|
||||
ENTRYPOINT ["/usr/local/bin/api"]
|
||||
@@ -0,0 +1,34 @@
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
|
||||
PKG := git.zb-server.de/ZB-Server/uptimesebi
|
||||
LDFLAGS := -s -w -X $(PKG)/internal/buildinfo.Version=$(VERSION) -X $(PKG)/internal/buildinfo.Commit=$(COMMIT)
|
||||
|
||||
.PHONY: generate web build test lint dev-up dev-down migrate image
|
||||
|
||||
generate:
|
||||
sqlc generate
|
||||
go tool templ generate
|
||||
|
||||
web:
|
||||
npm run build
|
||||
|
||||
build: generate web
|
||||
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/ ./cmd/...
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
lint:
|
||||
golangci-lint run
|
||||
|
||||
dev-up:
|
||||
docker compose up -d --wait
|
||||
|
||||
dev-down:
|
||||
docker compose down
|
||||
|
||||
migrate:
|
||||
go run ./cmd/api migrate up
|
||||
|
||||
image:
|
||||
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT=$(COMMIT) -t uptimesebi:$(VERSION) .
|
||||
@@ -0,0 +1,26 @@
|
||||
name: uptimesebi
|
||||
|
||||
services:
|
||||
timescaledb:
|
||||
image: timescale/timescaledb:2.30.1-pg16
|
||||
environment:
|
||||
POSTGRES_USER: uptime
|
||||
POSTGRES_PASSWORD: uptime
|
||||
POSTGRES_DB: uptime
|
||||
ports: ["5432:5432"]
|
||||
volumes: [pgdata:/var/lib/postgresql/data]
|
||||
healthcheck:
|
||||
test: ["CMD", "pg_isready", "-U", "uptime"]
|
||||
interval: 2s
|
||||
retries: 30
|
||||
|
||||
redis:
|
||||
image: redis:8-alpine
|
||||
ports: ["6379:6379"]
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 2s
|
||||
retries: 30
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
Reference in new issue
Block a user