Skip to content

Commit ec54000

Browse files
committed
build(docker): unify per-platform deploys behind single GHCR image
1 parent 4b354b7 commit ec54000

16 files changed

Lines changed: 233 additions & 560 deletions

File tree

.github/workflows/docker.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
paths:
10+
- Dockerfile
11+
- docker/**
12+
- src/**
13+
- iii-config*.yaml
14+
- package.json
15+
- tsdown.config.ts
16+
- tsconfig.json
17+
- .github/workflows/docker.yml
18+
workflow_dispatch:
19+
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: docker/setup-qemu-action@v3
30+
- uses: docker/setup-buildx-action@v3
31+
32+
- if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ghcr.io/${{ github.repository }}
43+
tags: |
44+
type=ref,event=branch
45+
type=ref,event=pr
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{major}}.{{minor}}
48+
type=semver,pattern={{major}}
49+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
50+
type=sha,prefix=sha-,format=short
51+
52+
- uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
platforms: linux/amd64,linux/arm64
56+
push: ${{ github.event_name != 'pull_request' }}
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max
61+
provenance: false

Dockerfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# syntax=docker/dockerfile:1
2+
ARG NODE_VERSION=22-slim
3+
ARG III_VERSION=0.11.2
4+
5+
FROM iiidev/iii:${III_VERSION} AS iii-image
6+
7+
FROM node:${NODE_VERSION} AS builder
8+
WORKDIR /build
9+
10+
COPY package.json tsdown.config.ts tsconfig.json ./
11+
RUN npm install --legacy-peer-deps --no-audit --no-fund
12+
13+
COPY src/ src/
14+
COPY iii-config.yaml iii-config.docker.yaml ./
15+
RUN npm run build
16+
17+
FROM node:${NODE_VERSION}
18+
ARG III_VERSION
19+
20+
RUN apt-get update \
21+
&& apt-get install -y --no-install-recommends \
22+
ca-certificates curl openssl tini tzdata \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
COPY --from=iii-image /app/iii /usr/local/bin/iii
26+
27+
WORKDIR /opt/agentmemory
28+
COPY --from=builder /build/dist ./dist
29+
COPY --from=builder /build/iii-config.yaml /build/iii-config.docker.yaml ./
30+
COPY --from=builder /build/package.json ./
31+
32+
# iii-sdk caret range would otherwise resolve newer than the pinned engine.
33+
RUN node -e "const p=require('./package.json'); p.overrides=Object.assign({},p.overrides,{'iii-sdk':process.env.III_VERSION}); require('fs').writeFileSync('package.json',JSON.stringify(p,null,2));" \
34+
&& III_VERSION="${III_VERSION}" npm install --omit=dev --legacy-peer-deps --no-audit --no-fund \
35+
&& ln -s /opt/agentmemory/dist/cli.mjs /usr/local/bin/agentmemory \
36+
&& mkdir -p /data \
37+
&& chown -R node:node /data /opt/agentmemory
38+
39+
ENV AGENTMEMORY_III_VERSION=${III_VERSION} \
40+
AGENTMEMORY_DATA_DIR=/data \
41+
AGENTMEMORY_HMAC_FILE=/data/.hmac \
42+
AGENTMEMORY_VIEWER_HOST=0.0.0.0 \
43+
NODE_ENV=production \
44+
TINI_SUBREAPER=1
45+
46+
COPY --chmod=0755 docker/entrypoint.sh /usr/local/bin/agentmemory-entrypoint.sh
47+
48+
EXPOSE 3111 3112 3113
49+
VOLUME ["/data"]
50+
51+
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
52+
CMD curl -fsS http://127.0.0.1:3111/agentmemory/livez || exit 1
53+
54+
USER node:node
55+
56+
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/agentmemory-entrypoint.sh"]

deploy/README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# One-click deploy templates
22

3-
Stand up agentmemory on managed infrastructure without rolling your own
4-
Docker host. Each template ships a self-contained Dockerfile that pulls
5-
`@agentmemory/agentmemory` from npm at build time and copies the iii
6-
engine binary in from the official `iiidev/iii` image — no pre-built
7-
agentmemory image required. Storage mounts at `/data`; an HMAC secret
8-
is generated by the first-boot entrypoint and persisted to the volume.
9-
The entrypoint overwrites the npm-bundled iii config with a
10-
deploy-tuned one that binds `0.0.0.0` and uses absolute `/data` paths,
11-
then drops privileges from `root` to `node` via `gosu` before
12-
exec'ing the agentmemory CLI.
3+
Stand up agentmemory on managed infrastructure. Each template pulls
4+
[`ghcr.io/rohitg00/agentmemory:latest`](https://github.com/rohitg00/agentmemory/pkgs/container/agentmemory)
5+
and mounts a volume at `/data`. The image generates the HMAC secret on
6+
first boot and persists it to the volume.
137

148
| Platform | Pitch | Cost floor |
159
|----------|-------|------------|

deploy/coolify/Dockerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

deploy/coolify/docker-compose.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
services:
2+
init:
3+
# chown the named volume to uid 1000 so the (non-root) agentmemory
4+
# container can write /data.
5+
image: busybox:1.36
6+
user: "0:0"
7+
volumes:
8+
- agentmemory-data:/data
9+
entrypoint: ["sh", "-c", "chown -R 1000:1000 /data && chmod 755 /data"]
10+
restart: "no"
11+
212
agentmemory:
3-
build:
4-
context: .
5-
dockerfile: Dockerfile
6-
args:
7-
AGENTMEMORY_VERSION: "0.9.12"
8-
III_VERSION: "0.11.2"
9-
III_SDK_VERSION: "0.11.2"
13+
# Pin to a semver tag for reproducible deploys; bump deliberately.
14+
image: ghcr.io/rohitg00/agentmemory:0.9.12
15+
depends_on:
16+
init:
17+
condition: service_completed_successfully
1018
restart: unless-stopped
1119
environment:
1220
- SERVICE_FQDN_AGENTMEMORY_3111

deploy/coolify/entrypoint.sh

Lines changed: 0 additions & 98 deletions
This file was deleted.

deploy/fly/Dockerfile

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)