Skip to content

Commit 3cd3c34

Browse files
authored
Add m365 CLI to aipcc-based image, build gog/m365 from our forks (#9)
* Add m365 CLI to aipcc-based CSB image npm install --prefix on a plain git URL failed silently: the fork lacked a "prepare" script, so npm never built dist/ before packing, leaving no m365 binary to symlink. Fixed upstream in tssala23/cli-microsoft365 by adding "prepare": "npm run build" (commit 6188d33), so the plain `npm install <git-url>#<commit>` + symlink now works as expected. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Pavel Anni <panni@redhat.com> * Build gog and m365 from our forks instead of upstream releases Both gogcli and cli-microsoft365 are forked (rh-forge) so we can ship changes ahead of upstream merge. Add a multi-stage build for gog from source (github.com/rh-forge/gogcli) instead of pulling an upstream release tarball, and point the m365 npm install at our fork (github.com/rh-forge/cli-microsoft365) instead of a coworker's fork. Also reclaim /sandbox ownership after both CLI installs, since m365's `m365 version` smoke test writes root-owned config under $HOME during the build. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Pavel Anni <panni@redhat.com> * Address CodeRabbit findings: pin base image digests, fix OpenShift GID-0 perms Pin both FROM images (golang builder, aipcc runtime base) to their current manifest-index digests so rebuilds can't silently pick up different image content. Also fix ownership/permissions on /sandbox for OpenShift's restricted-v2 SCC, which runs the container as an arbitrary UID but always keeps it in supplemental group 0: chown to <owner>:0 with chmod -R g=u instead of a fixed sandbox:sandbox owner with owner-only 0700, matching the pattern already used in Containerfile/Containerfile.hi/Containerfile.openclaw. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Pavel Anni <panni@redhat.com> * Document deferred CodeRabbit lockfile finding as inline TODO CodeRabbit flagged that the m365 fork install has no lockfile, so transitive npm deps can float between builds even at a pinned commit. Valid, but out of scope while we're still building images manually for testing (redhat-et/openclaw-csb has issues disabled, so track it inline instead of in a tracker). Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Pavel Anni <panni@redhat.com> --------- Signed-off-by: Pavel Anni <panni@redhat.com>
1 parent dd9feb5 commit 3cd3c34

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

csb/Containerfile.aipcc-based

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# ARG must precede the *first* FROM to be visible to every FROM in this file.
2+
ARG GO_VERSION=1.26.6
3+
4+
# --- gog CLI build stage ---------------------------------------------------
5+
# We forked gogcli (github.com/rh-forge/gogcli) to ship changes ahead of
6+
# upstream merge, so we build from our fork's source instead of pulling an
7+
# upstream release tarball. Mirrors gogcli's own Dockerfile build recipe.
8+
FROM golang:${GO_VERSION}-alpine@sha256:3889b425f035be855a72fb4755265311293b6d414521f0a519d819df32222d83 AS gogcli-build
9+
10+
RUN apk add --no-cache git ca-certificates
11+
12+
ARG GOGCLI_REPO=https://github.com/rh-forge/gogcli.git
13+
ARG GOGCLI_COMMIT=64744c2aad32745f907f08c5874e61b59b300054
14+
15+
WORKDIR /src
16+
RUN git clone "${GOGCLI_REPO}" . && git checkout "${GOGCLI_COMMIT}"
17+
18+
RUN set -eux; \
19+
VERSION="$(git describe --tags --always --dirty)"; \
20+
COMMIT="$(git rev-parse --short=12 HEAD)"; \
21+
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"; \
22+
CGO_ENABLED=0 GOOS=linux go build -trimpath \
23+
-ldflags="-s -w -X github.com/openclaw/gogcli/internal/cmd.version=${VERSION} -X github.com/openclaw/gogcli/internal/cmd.commit=${COMMIT} -X github.com/openclaw/gogcli/internal/cmd.date=${DATE}" \
24+
-o /out/gog ./cmd/gog
25+
26+
FROM quay.io/aipcc/base-images/agentic/openclaw:0.0.1-1787087976@sha256:251072c372f4b301b55160d2b6a8ce27a870a99c93d3402be2312f432a9b52ef
27+
28+
USER root
29+
30+
# OpenShift's restricted-v2 SCC runs the container as an arbitrary UID that
31+
# is not necessarily "sandbox", but always keeps it in supplemental group 0.
32+
# So paths gog/m365 need to read/write must be group-0-owned with group
33+
# perms mirroring owner perms, not owner-only 0700 pinned to a fixed UID.
34+
RUN mkdir -p /sandbox/.openclaw/state /run/secrets && \
35+
chown -R sandbox:0 /sandbox && \
36+
chmod -R g=u /sandbox/.openclaw && \
37+
chmod 755 /run/secrets
38+
39+
RUN microdnf install -y iproute nftables util-linux && \
40+
microdnf clean all
41+
42+
# gog CLI — built from our fork (github.com/rh-forge/gogcli) in the
43+
# gogcli-build stage above, since our changes haven't been released
44+
# upstream yet.
45+
COPY --from=gogcli-build /out/gog /usr/local/bin/gog
46+
RUN chmod 0755 /usr/local/bin/gog && gog --version
47+
48+
# m365 CLI — our fork of @pnp/cli-microsoft365 (github.com/rh-forge/cli-microsoft365),
49+
# pinned to a commit. The fork ships a "prepare": "npm run build" script, so
50+
# npm builds dist/ itself during the git-dependency install, same as it would
51+
# for any git-sourced package with a build step.
52+
# TODO(reproducibility): this git-dependency install has no lockfile, so the
53+
# fork's transitive npm deps can float between builds even at a fixed commit.
54+
# Deferred deliberately while we're still building images manually for
55+
# testing (PR #9 / CodeRabbit finding) — revisit before this goes past demo
56+
# use: add a committed package-lock.json to the fork and switch to `npm ci`.
57+
ARG M365_CLI_REPO=https://github.com/rh-forge/cli-microsoft365.git
58+
ARG M365_CLI_COMMIT=7c71c4806b9aee37bea78f7901fa6e818dbb95d8
59+
RUN set -eux; \
60+
npm install --prefix /opt/openclaw ${M365_CLI_REPO}#${M365_CLI_COMMIT}; \
61+
npm cache clean --force --prefix /opt/openclaw; \
62+
ln -s /opt/openclaw/node_modules/.bin/m365 /usr/local/bin/m365; \
63+
m365 version
64+
65+
ENV HOME=/sandbox \
66+
OPENCLAW_HOME=/sandbox \
67+
SQLITE_TMPDIR=/sandbox/.openclaw/state \
68+
TMPDIR=/sandbox/.openclaw/state
69+
70+
# Reclaim ownership of anything the CLI installs above wrote to $HOME while
71+
# running as root (e.g. m365's `configstore` creates
72+
# /sandbox/.config/configstore as root during its `m365 version` smoke test).
73+
# Group-0-own it (not just sandbox:sandbox) for the same OpenShift
74+
# arbitrary-UID reason as the mkdir/chown block above.
75+
RUN chown -R sandbox:0 /sandbox && chmod -R g=u /sandbox
76+
77+
USER sandbox
78+
79+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

0 commit comments

Comments
 (0)