- .coolify-bridge.yml: per-project config (slug, branches, previews) No UUIDs needed — bridge creates Coolify resources automatically - docker-compose.coolify.yml: Coolify-compatible compose with build directives, SERVICE_FQDN_FRONTEND_80, H2 profile for PR previews - infra/traefik/onedev.yml: Traefik dynamic config routing git.pele.cam → OneDev (deployed to /data/coolify/proxy/dynamic/) - coolify-bridge/: generic OneDev→Coolify bridge service FastAPI + APScheduler, auto-discovers all projects, find-or-create Coolify resources (project, server, env, apps), systemd service - .onedev-buildspec.yml: add optional notify step at end of CI
176 lines
5 KiB
YAML
176 lines
5 KiB
YAML
# OneDev CI/CD — CityGame monorepo
|
|
# Docs: https://docs.onedev.io/category/cicd
|
|
#
|
|
# Image CI recommandée (propriété ciBuildImage) :
|
|
# docker build -f ci/Dockerfile -t <registry>/citygame-ci:latest .
|
|
# docker push <registry>/citygame-ci:latest
|
|
# Puis Admin → Job Properties → ciBuildImage = <registry>/citygame-ci:latest
|
|
#
|
|
# Publication Docker (job Docker Publish) : configurer la connexion registry
|
|
# sur l'exécuteur Docker OneDev (voir tutorial Build/Publish Docker Image).
|
|
version: 47
|
|
properties:
|
|
- name: ciBuildImage
|
|
value: maven:3.9-eclipse-temurin-21
|
|
# Remplacer par votre image ci/Dockerfile publiée, ex. registry.example.com/citygame-ci:latest
|
|
jobs:
|
|
- name: Build and Test
|
|
steps:
|
|
- type: CheckoutStep
|
|
name: checkout
|
|
cloneCredential:
|
|
type: DefaultCredential
|
|
withLfs: false
|
|
withSubmodules: false
|
|
cloneDepth: 1
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
- type: SetupCacheStep
|
|
name: set up dependency caches
|
|
key: citygame-deps
|
|
checksumFiles: pnpm-lock.yaml apps/backend/pom.xml
|
|
paths:
|
|
- node_modules
|
|
- .pnpm-store
|
|
- .nx/cache
|
|
- .m2
|
|
uploadStrategy: UPLOAD_IF_NOT_EXACT_MATCH
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
- type: CommandStep
|
|
name: build and test
|
|
runInContainer: true
|
|
image: '@property:ciBuildImage@'
|
|
runAs: '0:0'
|
|
useTTY: false
|
|
interpreter:
|
|
type: DefaultInterpreter
|
|
commands: |
|
|
# OneDev exécute le script avec /bin/sh — lancer bash explicitement
|
|
bash -eo pipefail <<'EOS'
|
|
bash ci/setup-toolchain.sh
|
|
|
|
corepack enable
|
|
corepack prepare pnpm@@10.33.2 --activate
|
|
|
|
export CI=true
|
|
export HOME="$(pwd)"
|
|
mkdir -p .m2 reports/apps/frontend
|
|
|
|
pnpm install --frozen-lockfile
|
|
|
|
pnpm exec nx run-many -t build --parallel=2
|
|
pnpm exec nx run-many -t test --parallel=2
|
|
EOS
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
- type: PublishJUnitReportStep
|
|
name: publish test reports
|
|
reportName: Test Results
|
|
filePatterns: apps/backend/target/surefire-reports/**/*.xml reports/apps/frontend/**/*.xml
|
|
condition: ALWAYS
|
|
optional: false
|
|
- type: CommandStep
|
|
name: notify coolify-bridge
|
|
runInContainer: false
|
|
interpreter:
|
|
type: DefaultInterpreter
|
|
commands: |
|
|
# Ping the bridge so it syncs immediately instead of waiting for the next poll cycle.
|
|
# Non-fatal — if the bridge isn't running the deploy will happen on the next cycle.
|
|
curl -fsS -X POST http://localhost:8000/sync -o /dev/null \
|
|
&& echo "coolify-bridge notified" \
|
|
|| echo "coolify-bridge unreachable — deploy will happen on next poll cycle"
|
|
condition: SUCCESSFUL
|
|
optional: true
|
|
triggers:
|
|
# Branches stables (peu de pushes) : CI à chaque push direct
|
|
- type: BranchUpdateTrigger
|
|
branches: main master develop
|
|
userMatch: anyone
|
|
- type: PullRequestUpdateTrigger
|
|
branches: main master develop
|
|
retryCondition: never
|
|
timeout: 3600
|
|
- name: Docker Build
|
|
steps:
|
|
- type: CheckoutStep
|
|
name: checkout
|
|
cloneCredential:
|
|
type: DefaultCredential
|
|
withLfs: false
|
|
withSubmodules: false
|
|
cloneDepth: 1
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
- type: BuildImageStep
|
|
name: build frontend image
|
|
buildPath: .
|
|
dockerfile: apps/frontend/Dockerfile
|
|
output:
|
|
type: OCIOutput
|
|
destPath: .docker-oci/frontend
|
|
platforms: linux/amd64
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
- type: BuildImageStep
|
|
name: build backend image
|
|
buildPath: .
|
|
dockerfile: apps/backend/Dockerfile
|
|
output:
|
|
type: OCIOutput
|
|
destPath: .docker-oci/backend
|
|
platforms: linux/amd64
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
jobDependencies:
|
|
- jobName: Build and Test
|
|
requireSuccessful: true
|
|
triggers:
|
|
- type: BranchUpdateTrigger
|
|
branches: main master develop
|
|
userMatch: anyone
|
|
- type: PullRequestUpdateTrigger
|
|
branches: main master develop
|
|
retryCondition: never
|
|
timeout: 7200
|
|
- name: Docker Publish
|
|
steps:
|
|
- type: CheckoutStep
|
|
name: checkout
|
|
cloneCredential:
|
|
type: DefaultCredential
|
|
withLfs: false
|
|
withSubmodules: false
|
|
cloneDepth: 1
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
- type: BuildImageStep
|
|
name: publish frontend image
|
|
buildPath: .
|
|
dockerfile: apps/frontend/Dockerfile
|
|
output:
|
|
type: RegistryOutput
|
|
tags: citygame-frontend:latest citygame-frontend:@build_version@
|
|
platforms: linux/amd64
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
- type: BuildImageStep
|
|
name: publish backend image
|
|
buildPath: .
|
|
dockerfile: apps/backend/Dockerfile
|
|
output:
|
|
type: RegistryOutput
|
|
tags: citygame-backend:latest citygame-backend:@build_version@
|
|
platforms: linux/amd64
|
|
condition: SUCCESSFUL
|
|
optional: false
|
|
jobDependencies:
|
|
- jobName: Docker Build
|
|
requireSuccessful: true
|
|
triggers:
|
|
- type: BranchUpdateTrigger
|
|
branches: main master
|
|
userMatch: anyone
|
|
retryCondition: never
|
|
timeout: 7200
|