Skip to content

Deploying an Onedev App

Introduction

Onedev is an open-source Git server with CI/CD and issue tracking built in. Deploying Onedev with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage for repositories and builds—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample API usage, and production tips.


Prerequisites

  • A Klutch.sh account (sign up)
  • A GitHub repository containing your Onedev Dockerfile (GitHub is the only supported git source)
  • Storage sizing for repositories, artifacts, and logs
  • Optional SMTP credentials for notifications

For onboarding, see the Quick Start.


Architecture and ports

  • Onedev serves HTTP on internal port 6610; choose HTTP traffic.
  • SSH for Git over SSH uses port 6611; if you need SSH, set TCP and expose 6611 as well.
  • Persistent storage is required for repositories, build artifacts, and logs.

Repository layout

onedev/
├── Dockerfile # Must be at repo root for auto-detection
└── README.md

Keep secrets (admin credentials, SMTP passwords) out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Validate locally before pushing to GitHub:

Terminal window
docker build -t onedev-local .
docker run -p 6610:6610 -p 6611:6611 onedev-local

Dockerfile for Onedev (production-ready)

Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):

FROM 1dev/server:latest
ENV HTTP_PORT=6610 \
SSH_PORT=6611
EXPOSE 6610 6611
CMD ["/bin/sh", "-c", "exec /opt/onedev/bin/server.sh --http-port ${HTTP_PORT} --ssh-port ${SSH_PORT}"]

Notes:

  • Pin the image tag (e.g., 1dev/server:10.3.x) for stability and upgrade intentionally.
  • If you do not use SSH, you can omit port 6611 and adjust the start command.

Environment variables (Klutch.sh)

Set these in Klutch.sh before deploying:

  • HTTP_PORT=6610
  • SSH_PORT=6611 (optional if you use SSH)
  • Optional JVM/memory tuning: JAVA_OPTS="-Xms1g -Xmx1g"
  • SMTP (optional): ONDEV_SMTP_HOST, ONDEV_SMTP_PORT, ONDEV_SMTP_USER, ONDEV_SMTP_PASSWORD, ONDEV_SMTP_FROM

If you deploy without the Dockerfile and need Nixpacks overrides:

  • NIXPACKS_START_CMD=/opt/onedev/bin/server.sh --http-port 6610 --ssh-port 6611

Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required):

  • /opt/onedev — repositories, configs, build logs, and artifacts.

Ensure this path is writable inside the container.


Deploy Onedev on Klutch.sh (Dockerfile workflow)

  1. Push your repository—with the Dockerfile at the root—to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  3. Select HTTP traffic and set the internal port to 6610. If you need SSH, configure a second TCP app or port for 6611.
  4. Add the environment variables above, including any SMTP or JVM tuning settings.
  5. Attach a persistent volume for /opt/onedev sized for your repositories and build artifacts.
  6. Deploy. Access Onedev at https://example-app.klutch.sh; complete the setup wizard to create the admin account.

Sample API usage

List projects (replace token with your access token):

Terminal window
curl -X GET "https://example-app.klutch.sh/api/projects" \
-H "Authorization: Bearer <token>"

Create a project:

Terminal window
curl -X POST "https://example-app.klutch.sh/api/projects" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"name":"demo","description":"Demo project"}'

Health checks and production tips

  • Add an HTTP probe to / or /api/projects for readiness (authentication may be required; use a lightweight public page if available).
  • Enforce HTTPS at the edge; forward internally to port 6610.
  • Keep admin and SMTP credentials in Klutch.sh secrets; rotate them regularly.
  • Monitor /opt/onedev storage; resize before it fills. Back up repositories and configs before upgrades.
  • Pin image versions and test upgrades in staging.

Onedev on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 6610 configured, and storage persisted, you can host Git repos and CI/CD pipelines without extra YAML or workflow overhead.