diff --git a/Containerfile b/Containerfile index 149dfe07..3e5b3549 100644 --- a/Containerfile +++ b/Containerfile @@ -28,5 +28,9 @@ 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"] diff --git a/internal/procctl/procctl.go b/internal/procctl/procctl.go index d1cd85d6..60fd3c23 100644 --- a/internal/procctl/procctl.go +++ b/internal/procctl/procctl.go @@ -525,7 +525,12 @@ func (m *Manager) ReadEnvGroups() ([]EnvGroup, error) { tmplPath := filepath.Join(m.Root, ".env.example") tmplData, err := os.ReadFile(tmplPath) if os.IsNotExist(err) { - return nil, nil + // A nil slice here would marshal to JSON null instead of [] -- the + // admin UI's env editor unconditionally calls .reduce()/.map() on + // this response and crashes on null. .env.example isn't shipped + // inside the container image, so this path is the normal case in + // production, not an edge case. + return []EnvGroup{}, nil } if err != nil { return nil, fmt.Errorf("read .env.example: %w", err)