diff --git a/.komodo/resources.toml b/.komodo/resources.toml new file mode 100644 index 0000000..a85bc80 --- /dev/null +++ b/.komodo/resources.toml @@ -0,0 +1,52 @@ +[[build]] +name = "komodo-demo-build" +description = "Build Docker image for komodo-demo app" +tags = ["demo", "gitea"] + +[build.config] +# Repo configuration +git_provider = "gitea.straymoog.xyz" +git_account = "stray" +repo = "stray/komodo-demo" +branch = "main" + +# Build configuration +build_path = "." +dockerfile_path = "Dockerfile" + +# Image configuration +image_registry = "local" +image_name = "komodo-demo-app" +image_tag = "latest" + +[[stack]] +name = "komodo-demo-stack" +description = "Deploy komodo-demo app using docker-compose" +tags = ["demo", "gitea"] + +[stack.config] +# Use compose file from git repo +[stack.config.repo] +git_provider = "gitea.straymoog.xyz" +git_account = "stray" +repo = "stray/komodo-demo" +branch = "main" +path = "docker-compose.yml" + +# Or optionally, define inline compose content +# file_contents = ''' +# ... compose yaml here ... +# ''' + +[[sync]] +name = "komodo-demo-sync" +description = "Sync Komodo resources from Git" +tags = ["demo", "gitea"] + +[sync.config] +git_provider = "gitea.straymoog.xyz" +git_account = "stray" +repo = "stray/komodo-demo" +branch = "main" +resource_path = ".komodo" +commit_to_repo = false diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..638fcf7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY package*.json ./ +RUN npm install --production + +COPY . . + +EXPOSE 3000 + +CMD ["npm", "start"] diff --git a/README.md b/README.md index 4363fca..040a750 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,44 @@ -# komodo-demo +# Komodo + Gitea Integration Demo -Demo repository for Komodo integration with Gitea \ No newline at end of file +This repository demonstrates the integration between Komodo and Gitea. + +## What's Included + +### Application +- **app.js**: Simple Express.js web server +- **package.json**: Node.js dependencies +- **Dockerfile**: Container build configuration + +### Docker Compose +- **docker-compose.yml**: Stack deployment configuration + +### Komodo Configuration +- **.komodo/resources.toml**: Komodo resource definitions + - **Build**: Builds Docker image from Dockerfile + - **Stack**: Deploys app using docker-compose + - **Sync**: Syncs Komodo resources from Git + +## Integration Features + +1. **Webhook-Driven Builds**: Push to `main` branch triggers automatic Docker image build +2. **Automated Deployment**: Built images can be automatically deployed via Stack resource +3. **GitOps Configuration**: Manage Komodo resources in Git using Resource Sync + +## API Endpoints + +- `GET /`: Returns app info and timestamp +- `GET /health`: Health check endpoint + +## Setup + +1. Configure Gitea access token in Komodo +2. Create Build, Stack, and Sync resources in Komodo +3. Set up webhooks in Gitea pointing to Komodo +4. Push changes to trigger automation + +## Testing + +Push changes to the repository and watch Komodo: +- Build the Docker image +- Deploy the updated stack +- Sync configuration changes diff --git a/app.js b/app.js new file mode 100644 index 0000000..6c55731 --- /dev/null +++ b/app.js @@ -0,0 +1,19 @@ +const express = require('express'); +const app = express(); +const PORT = process.env.PORT || 3000; + +app.get('/', (req, res) => { + res.json({ + message: 'Hello from Komodo Demo!', + version: '1.0.0', + timestamp: new Date().toISOString() + }); +}); + +app.get('/health', (req, res) => { + res.json({ status: 'healthy' }); +}); + +app.listen(PORT, () => { + console.log(`Komodo demo app running on port ${PORT}`); +}); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cab1c17 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3.8' + +services: + app: + image: komodo-demo-app:latest + container_name: komodo-demo-app + ports: + - "3000:3000" + environment: + - PORT=3000 + - NODE_ENV=production + restart: unless-stopped + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s diff --git a/package.json b/package.json new file mode 100644 index 0000000..4a1115c --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "komodo-demo-app", + "version": "1.0.0", + "description": "Demo app for Komodo + Gitea integration", + "main": "app.js", + "scripts": { + "start": "node app.js" + }, + "dependencies": { + "express": "^4.18.2" + } +}