dev: add Docker compose development stack with Air reload
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
root = "."
|
||||||
|
tmp_dir = "tmp"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
cmd = "go build -o ./tmp/goyomi ./cmd/server"
|
||||||
|
bin = "./tmp/goyomi"
|
||||||
|
include_ext = ["go", "tpl", "tmpl", "html", "yaml", "yml", "json"]
|
||||||
|
exclude_dir = ["tmp", "vendor", ".git"]
|
||||||
|
delay = 500
|
||||||
|
stop_on_error = true
|
||||||
|
|
||||||
|
[log]
|
||||||
|
time = true
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
FROM golang:1.26-alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache git bash build-base
|
||||||
|
RUN go install github.com/air-verse/air@latest
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
CMD ["air", "-c", ".air.toml"]
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
DEV_COMPOSE = docker compose -f compose-dev.yml --env-file dev.env
|
||||||
|
|
||||||
|
.PHONY: dev-up dev-shell dev-down dev-logs dev-build dev-run
|
||||||
|
|
||||||
|
dev-build:
|
||||||
|
$(DEV_COMPOSE) build dev
|
||||||
|
|
||||||
|
dev-up:
|
||||||
|
$(DEV_COMPOSE) up -d
|
||||||
|
|
||||||
|
dev-run:
|
||||||
|
$(DEV_COMPOSE) up dev
|
||||||
|
|
||||||
|
dev-shell:
|
||||||
|
$(DEV_COMPOSE) exec dev sh
|
||||||
|
|
||||||
|
dev-down:
|
||||||
|
$(DEV_COMPOSE) down
|
||||||
|
|
||||||
|
dev-logs:
|
||||||
|
$(DEV_COMPOSE) logs -f --tail=100
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
services:
|
||||||
|
dev:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
working_dir: /workspace
|
||||||
|
command: air -c .air.toml
|
||||||
|
tty: true
|
||||||
|
stdin_open: true
|
||||||
|
env_file:
|
||||||
|
- dev.env
|
||||||
|
volumes:
|
||||||
|
- ./:/workspace
|
||||||
|
- go_mod_cache:/go/pkg/mod
|
||||||
|
- go_build_cache:/root/.cache/go-build
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
flaresolverr:
|
||||||
|
condition: service_started
|
||||||
|
networks:
|
||||||
|
- goyomi_dev
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- dev.env
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- postgres_dev_data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
networks:
|
||||||
|
- goyomi_dev
|
||||||
|
|
||||||
|
flaresolverr:
|
||||||
|
image: ghcr.io/flaresolverr/flaresolverr:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- dev.env
|
||||||
|
environment:
|
||||||
|
LOG_LEVEL: ${FLARESOLVERR_LOG_LEVEL}
|
||||||
|
ports:
|
||||||
|
- "8191:8191"
|
||||||
|
networks:
|
||||||
|
- goyomi_dev
|
||||||
|
|
||||||
|
networks:
|
||||||
|
goyomi_dev:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
go_mod_cache:
|
||||||
|
go_build_cache:
|
||||||
|
postgres_dev_data:
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# PostgreSQL
|
||||||
|
POSTGRES_DB=goyomi
|
||||||
|
POSTGRES_USER=goyomi
|
||||||
|
POSTGRES_PASSWORD=goyomi
|
||||||
|
|
||||||
|
# App runtime
|
||||||
|
DATABASE_URL=postgres://goyomi:goyomi@postgres:5432/goyomi?sslmode=disable
|
||||||
|
FLARESOLVERR_URL=http://flaresolverr:8191
|
||||||
|
ADDR=:8080
|
||||||
|
|
||||||
|
# DB pool
|
||||||
|
DB_MAX_CONNS=10
|
||||||
|
DB_MIN_CONNS=2
|
||||||
|
|
||||||
|
# Cache TTLs (seconds)
|
||||||
|
MANGA_LIST_TTL_SECONDS=600
|
||||||
|
MANGA_DETAIL_TTL_SECONDS=3600
|
||||||
|
CHAPTER_LIST_TTL_SECONDS=600
|
||||||
|
|
||||||
|
# FlareSolverr
|
||||||
|
FLARESOLVERR_LOG_LEVEL=info
|
||||||
Reference in New Issue
Block a user