Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 45d3469376 | |||
| ef0c472e28 | |||
| 0a620720b6 | |||
| 0a8ca9b751 | |||
| 7778ba4315 | |||
| 850d6ed58c | |||
| 88ab5fa893 | |||
| fa685fd63e | |||
| e1fab4f11f | |||
| 0526268333 | |||
| 8682d4587a | |||
| 293cb50d4a | |||
| caa18faff0 | |||
| 1c50016d80 | |||
| e21758978a | |||
| a261bdc030 | |||
| b6a9577eee | |||
| 993c749a89 | |||
| 29ddd3f23b | |||
| a9fa841569 | |||
| f1d828bfe3 | |||
| be4711f646 | |||
| 0ba3f170fd | |||
| ae9adb3c8a | |||
| b97f91546a | |||
| 06453428ec | |||
| 5698cbb1dc | |||
| 64efc540ce | |||
| 9abc442574 | |||
| 7ffc2f7e4f | |||
| d7acd23316 | |||
|
990aceff0e
|
|||
| b7bd789d99 | |||
| 93ba3a92d2 | |||
| 804d541ff8 | |||
| f183ef05b4 | |||
| 5f119f2a62 | |||
| 9443098774 | |||
| 3923c95b30 |
@@ -0,0 +1,45 @@
|
|||||||
|
name: Nightly Rebuild
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
hadolint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||||
|
with:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
|
build-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
|
||||||
|
- uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- id: get-latest-tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||||
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
- id: meta
|
||||||
|
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
||||||
|
with:
|
||||||
|
images: jcabillot/opencode
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest
|
||||||
|
type=raw,value=${{ steps.get-latest-tag.outputs.tag }},enable=${{ steps.get-latest-tag.outputs.tag != '' }}
|
||||||
|
- uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
pull: true
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
name: Docker Build and Push
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v4
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v4
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Docker metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v6
|
|
||||||
with:
|
|
||||||
images: jcabillot/opencode
|
|
||||||
tags: |
|
|
||||||
#type=ref,event=branch
|
|
||||||
#type=ref,event=pr
|
|
||||||
#type=sha
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v7
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
pull: true
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
name: Main Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
hadolint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||||
|
with:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
|
build-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
|
||||||
|
- uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- id: meta
|
||||||
|
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
||||||
|
with:
|
||||||
|
images: jcabillot/opencode
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest
|
||||||
|
- uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
pull: true
|
||||||
|
|
||||||
|
tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Configure git auth
|
||||||
|
run: |
|
||||||
|
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@scm.cabillot.eu/perso/opencode.git"
|
||||||
|
- uses: anothrNick/github-tag-action@4ed44965e0db8dab2b466a16da04aec3cc312fd8 # v1.75.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
DEFAULT_BUMP: patch
|
||||||
|
RELEASE_BRANCHES: main
|
||||||
|
WITH_V: true
|
||||||
|
GIT_API_TAGGING: false
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
name: PR Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
hadolint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||||
|
with:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
|
||||||
|
- uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: false
|
||||||
|
pull: true
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
name: Tag Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ['*']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
hadolint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||||
|
with:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
|
build-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
|
||||||
|
- uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- id: meta
|
||||||
|
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
||||||
|
with:
|
||||||
|
images: jcabillot/opencode
|
||||||
|
tags: |
|
||||||
|
type=ref,event=tag
|
||||||
|
- uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
pull: true
|
||||||
@@ -2,33 +2,40 @@
|
|||||||
|
|
||||||
## Project overview
|
## Project overview
|
||||||
|
|
||||||
This repository builds and publishes a Docker image for [OpenCode](https://opencode.ai), the open source AI coding agent. The image runs OpenCode in headless server mode (`opencode serve`) and is automatically rebuilt and pushed to Docker Hub (`jcabillot/opencode`) every night by a Jenkins pipeline.
|
This repository builds and publishes a Docker image for [OpenCode](https://opencode.ai), the open source AI coding agent. The image runs OpenCode in headless server mode (`opencode serve`) and is automatically rebuilt and pushed to Docker Hub (`jcabillot/opencode`) every night by a Gitea Actions pipeline.
|
||||||
|
|
||||||
## Repository structure
|
## Repository structure
|
||||||
|
|
||||||
```
|
```
|
||||||
.
|
.
|
||||||
├── Dockerfile # Image definition
|
├── Dockerfile # Image definition
|
||||||
├── Jenkinsfile # CI/CD pipeline (nightly build + Docker Hub push)
|
├── .gitea/workflows/docker-build.yaml # CI/CD pipeline (Gitea Actions)
|
||||||
├── opencode-attach # Helper script for attaching to a running server
|
├── renovate.json # Dependency update automation (Renovatebot)
|
||||||
└── README.md # Usage documentation
|
├── opencode-attach # Helper script for attaching to a running server
|
||||||
|
└── README.md # Usage documentation
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Dependency management
|
||||||
|
|
||||||
|
- **Always pin versions** in the Dockerfile `npm install` command (e.g. `opencode-ai@1.16.2 n2-soul@9.0.9`). Never leave packages unpinned.
|
||||||
|
- **Update renovate customManagers** when adding, removing, or renaming a dependency tracked in the Dockerfile. Each pinned package must have a corresponding `customManager` entry in `renovate.json` with a regex `matchStrings` pattern that captures the version. If a dependency is added without a renovate entry, Renovatebot will not open automated PRs for it.
|
||||||
|
- **apt packages** (apt-get install lines in Dockerfile) and **COPY --from** image references are not currently tracked by Renovate. Pinning these manually is acceptable for now but adding renovate managers for them is encouraged.
|
||||||
|
|
||||||
## Dockerfile conventions
|
## Dockerfile conventions
|
||||||
|
|
||||||
- **Base image**: `node:24` — Debian-based Node.js image (not Alpine, needed for apt packages).
|
- **Base image**: `node:24` — Debian-based Node.js image (not Alpine, needed for apt packages).
|
||||||
- **Install**: `npm i -g opencode-ai n2-soul@<version>` — installs OpenCode and Soul globally.
|
- **Install**: `npm i -g opencode-ai@<version> n2-soul@<version>` — installs OpenCode and Soul globally, both pinned.
|
||||||
- **Version check**: `RUN opencode --version` after install to validate the build and record the installed version in build logs.
|
- **Version check**: `RUN opencode --version` after install to validate the build and record the installed version in build logs.
|
||||||
- **Dedicated user**: a non-root `opencode` user and group are created with `groupadd`/`useradd` (UID/GID 1000). All runtime steps run as this user.
|
- **Dedicated user**: a non-root `opencode` user and group are created with `groupadd`/`useradd` (UID/GID 1000). All runtime steps run as this user.
|
||||||
- **Cluster tooling**: `kubectl` is copied from the official `registry.k8s.io/kubectl` image (multi-stage COPY).
|
- **Cluster tooling**: `kubectl` is copied from the official `registry.k8s.io/kubectl` image (multi-stage COPY).
|
||||||
- **Entrypoint**: `["opencode"]` — arguments are passed at runtime (e.g. `serve`).
|
- **Entrypoint**: `["opencode"]` — arguments are passed at runtime (e.g. `serve`).
|
||||||
|
|
||||||
## Jenkinsfile conventions
|
## CI/CD conventions (Gitea Actions)
|
||||||
|
|
||||||
- The pipeline runs on a `@midnight` cron trigger for nightly rebuilds.
|
- Pipeline triggers on push to `main`, PRs targeting `main`, and a nightly cron (`cron: '0 0 * * *'`).
|
||||||
- Build uses `--no-cache --pull` to always fetch the latest base image and package version.
|
- Image is pushed to Docker Hub only on non-PR events (main branch pushes and cron runs).
|
||||||
- Docker Hub credentials are stored under the `dockerhub_jcabillot` Jenkins credential ID.
|
- Docker Hub credentials are stored in Gitea Actions secrets (`DOCKERHUB_USERNAME`, `DOCKERHUB_TOKEN`).
|
||||||
- The image is published as `jcabillot/opencode` (no explicit tag = `latest`).
|
- The image is published as `jcabillot/opencode:latest` with digest and branch tags.
|
||||||
|
|
||||||
## Useful commands
|
## Useful commands
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
FROM node:26-trixie
|
FROM node:24-trixie
|
||||||
|
|
||||||
ENV NPM_CONFIG_UPDATE_NOTIFIER=false \
|
ENV NPM_CONFIG_UPDATE_NOTIFIER=false \
|
||||||
NPM_CONFIG_LOGLEVEL=warn \
|
NPM_CONFIG_LOGLEVEL=warn \
|
||||||
@@ -12,12 +12,12 @@ RUN apt-get update && \
|
|||||||
groupadd -g 1000 opencode; \
|
groupadd -g 1000 opencode; \
|
||||||
useradd -m -u 1000 -g 1000 -s /usr/bin/bash opencode; \
|
useradd -m -u 1000 -g 1000 -s /usr/bin/bash opencode; \
|
||||||
npm update -g --no-fund --no-audit && \
|
npm update -g --no-fund --no-audit && \
|
||||||
npm install -g --no-fund --no-audit opencode-ai n2-soul@9.0.9 && \
|
npm install -g --no-fund --no-audit opencode-ai@1.16.2 n2-soul@9.0.9 && \
|
||||||
npm cache clean --force && \
|
npm cache clean --force && \
|
||||||
chown -R 1000:1000 /usr/local/lib/node_modules/n2-soul/
|
chown -R 1000:1000 /usr/local/lib/node_modules/n2-soul/
|
||||||
|
|
||||||
COPY --chmod=755 opencode-attach /usr/local/bin/opencode-attach
|
COPY --chmod=755 opencode-attach /usr/local/bin/opencode-attach
|
||||||
COPY --from=registry.k8s.io/kubectl:v1.36.1 /bin/kubectl /usr/local/bin/kubectl
|
COPY --from=registry.k8s.io/kubectl:v1.36.2 /bin/kubectl /usr/local/bin/kubectl
|
||||||
|
|
||||||
USER opencode
|
USER opencode
|
||||||
WORKDIR /home/opencode
|
WORKDIR /home/opencode
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"customManagers": [
|
||||||
|
{
|
||||||
|
"customType": "regex",
|
||||||
|
"description": "Track n2-soul npm package pinned in Dockerfile RUN command",
|
||||||
|
"managerFilePatterns": ["/^Dockerfile$/"],
|
||||||
|
"matchStrings": ["n2-soul@(?<currentValue>[^\\s]+)"],
|
||||||
|
"depNameTemplate": "n2-soul",
|
||||||
|
"datasourceTemplate": "npm",
|
||||||
|
"versioningTemplate": "npm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"customType": "regex",
|
||||||
|
"description": "Track opencode-ai npm package pinned in Dockerfile RUN command",
|
||||||
|
"managerFilePatterns": ["/^Dockerfile$/"],
|
||||||
|
"matchStrings": ["opencode-ai@(?<currentValue>[^\\s]+)"],
|
||||||
|
"depNameTemplate": "opencode-ai",
|
||||||
|
"datasourceTemplate": "npm",
|
||||||
|
"versioningTemplate": "npm"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user