owpengram-server/Containerfile
Astra 4cbd4c0c9e
Some checks failed
CI / Go tests (push) Has been cancelled
CI / Admin web build (push) Has been cancelled
CI / Grammy store bot (push) Has been cancelled
CI / Docker main topology smoke (push) Has been cancelled
admin: fix env editor crash and ship .env.example into the image
ReadEnvGroups returned (nil, nil) when .env.example wasn't found, and that
nil slice marshaled to JSON null instead of []. The admin UI's env editor
unconditionally calls .reduce()/.map() on the response, so it crashed on
load with "Cannot read properties of null" -- and .env.example was never
copied into the container image in the first place, so this was always the
production code path, not an edge case.

Fixed the nil-slice response and added .env.example to the image so the
editor actually has a template of available settings to show. The real
current values still require the deploy host to mount its actual .env file
into the owpengram-admin container at /app/.env (procctl.Manager.Root is
just os.Getwd(), i.e. the container's /app workdir) -- that's a systemd
Quadlet unit change on the deploy host, not something this commit can fix on
its own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-14 17:02:02 +01:00

36 lines
1.7 KiB
Docker

FROM docker.io/library/golang:1.25 AS build
# Build metadata for telesrv's startup log (git_commit/git_branch/... in
# cmd/telesrv/buildinfo.go). .containerignore excludes .git, so go build's
# automatic VCS stamping sees no repo; pass these in explicitly, e.g.:
# podman build \
# --build-arg GIT_COMMIT="$(git rev-parse HEAD)" \
# --build-arg GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" \
# --build-arg GIT_TREE_STATE="$(git diff --quiet && echo clean || echo dirty)" \
# --build-arg BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
# -t owpengram-server -f Containerfile .
ARG GIT_COMMIT=unknown
ARG GIT_BRANCH=unknown
ARG GIT_TREE_STATE=unknown
ARG BUILD_TIME=unknown
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -trimpath \
-ldflags "-X main.gitCommit=${GIT_COMMIT} -X main.gitBranch=${GIT_BRANCH} -X main.gitTreeState=${GIT_TREE_STATE} -X main.buildTime=${BUILD_TIME}" \
-o /out/gramsrv ./cmd/telesrv
RUN CGO_ENABLED=0 go build -trimpath -o /out/telesrv-admin ./cmd/telesrv-admin
RUN CGO_ENABLED=0 go build -trimpath -o /out/createuser ./cmd/createuser
FROM docker.io/library/alpine:3.20
RUN apk add --no-cache ca-certificates tzdata ffmpeg
WORKDIR /app
COPY --from=build /out/gramsrv /app/gramsrv
COPY --from=build /out/telesrv-admin /app/telesrv-admin
COPY --from=build /out/createuser /app/createuser
COPY --from=build /src/data/langpack /app/data/langpack
COPY --from=build /src/data/sticker-seed /app/data/sticker-seed
# telesrv-admin's Server Settings env editor (procctl.Manager.ReadEnvGroups)
# reads this as the template of available settings; without it the editor
# always reports zero groups.
COPY --from=build /src/.env.example /app/.env.example
EXPOSE 2398 2600
ENTRYPOINT ["/app/gramsrv"]