8000 feat: add Docker packaging support by youyao666 · Pull Request #6 · XxxXTeam/geminiweb2api · GitHub
[go: up one dir, main page]

Skip to content

feat: add Docker packaging support - #6

Merged
chanhanzhan merged 3 commits into
XxxXTeam:mainfrom
youyao666:pr-docker-only
May 1, 2026
Merged

chanhanzhan merged 3 commits into
XxxXTeam:mainfrom
youyao666:pr-docker-only

Conversation

@youyao666
Copy link
Copy Markdown
Contributor

Summary

  • add a multi-stage Dockerfile for this Go service
  • add docker-compose and a config example for container startup
  • document Docker build and run usage in both README files

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds container packaging and run documentation for this Go service so it can be built and started via Docker/Docker Compose with a mounted config.json.

Changes:

  • Added a multi-stage Dockerfile to build and run the cmd/geminiweb2api binary in a minimal runtime image
  • Added docker-compose.yml, .dockerignore, and a config.json.example for container startup
  • Updated README.md and ZH_CN.md with Docker build/run/compose instructions

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
Dockerfile Multi-stage build and runtime image definition for the service
docker-compose.yml Compose service definition to build and run the container with config bind-mount
.dockerignore Reduces Docker build context (excludes git metadata, local config, etc.)
config.json.example Provides a starter config for users to copy/mount into the container
README.md Documents Docker build/run/compose usage (English)
ZH_CN.md Documents Docker build/run/compose usage (Chinese)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ZH_CN.md
Comment on lines +60 to +67
挂载本地 `config.json` 运行容器:

```bash
docker run -d \
--name geminiweb2api \
-p 8080:8080 \
-v $(pwd)/config.json:/app/config.json \
geminiweb2api:latest
Copilot AI Apr 19, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker run 示例里直接挂载 ./config.json,但没有提示先创建该文件。如果宿主机上不存在 config.json,Docker 往往会在该路径创建一个“同名目录”并挂载到 /app/config.json,导致程序读取配置时报错。建议在运行命令前补充一步(例如从 config.json.example 复制)。

Copilot uses AI. Check for mistakes.
Comment thread Dockerfile
@@ -0,0 +1,25 @@
FROM golang:1.25-alpine AS builder
Copilot AI Apr 19, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The builder image is pinned to golang:1.25-alpine, but go.mod declares go 1.25.5. Using different patch versions can lead to subtle build differences and makes reproducing builds harder. Consider pinning the Docker builder image to the same patch level (or introducing a single ARG GO_VERSION used by both tooling/docs).

Suggested change
FROM golang:1.25-alpine AS builder
FROM golang:1.25.5-alpine AS builder

Copilot uses AI. Check for mistakes.
Comment thread Dockerfile
Comment on lines +17 to +24
RUN apk add --no-cache ca-certificates tzdata && update-ca-certificates

COPY --from=builder /out/geminiweb2api /app/geminiweb2api

EXPOSE 8080

VOLUME ["/app"]

Copilot AI Apr 19, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime image runs as root by default. For a network-exposed service, it’s safer to create a dedicated user/group and USER it in the final stage (ensuring /app is readable/executable). This reduces impact if the process is compromised.

Suggested change
RUN apk add --no-cache ca-certificates tzdata && update-ca-certificates
COPY --from=builder /out/geminiweb2api /app/geminiweb2api
EXPOSE 8080
VOLUME ["/app"]
RUN apk add --no-cache ca-certificates tzdata && update-ca-certificates \
&& addgroup -S app \
&& adduser -S -G app -h /app app
COPY --from=builder --chown=app:app /out/geminiweb2api /app/geminiweb2api
EXPOSE 8080
VOLUME ["/app"]
USER app:app

Copilot uses AI. Check for mistakes.
Comment thread docker-compose.yml Resolved
Comment thread README.md
Comment on lines +87 to +89
-e HTTP_PROXY=http://host.docker.internal:7890 \
-e HTTPS_PROXY=http://host.docker.internal:7890 \
geminiweb2api:latest
Copilot AI Apr 19, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxy example uses host.docker.internal, which works on Docker Desktop but isn’t available by default on many Linux setups. Consider noting the Linux alternative (e.g., --add-host=host.docker.internal:host-gateway or using the host’s IP) so users don’t get a confusing proxy connection failure.

Copilot uses AI. Check for mistakes.
Comment thread Dockerfile

COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /out/geminiweb2api ./cmd/geminiweb2api
Copilot AI Apr 19, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build step hard-codes GOARCH=amd64. On ARM hosts (e.g., Apple Silicon), docker build will produce an amd64 binary but the final alpine stage will default to arm64, leading to an "exec format error" at runtime. Consider using BuildKit’s TARGETOS/TARGETARCH (and --platform) or removing the hard-coded GOARCH so the binary matches the target platform.

Copilot uses AI. Check for mistakes.
Comment thread Dockerfile
Comment on lines +23 to +24
VOLUME ["/app"]

Copilot AI Apr 19, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VOLUME ["/app"] will create an anonymous volume on container start, which can leave orphaned volumes on repeated runs and can surprise users when inspecting/removing containers. Since the documented usage bind-mounts only /app/config.json, consider removing the VOLUME declaration (or scoping persistence to a dedicated data directory if needed).

Suggested change
VOLUME ["/app"]

Copilot uses AI. Check for mistakes.
Comment thread ZH_CN.md Resolved
Comment thread config.json.example Resolved
Comment thread README.md
Comment on lines +60 to +67
Run with a local `config.json` mounted into the container:

```bash
docker run -d \
--name geminiweb2api \
-p 8080:8080 \
-v $(pwd)/config.json:/app/config.json \
geminiweb2api:latest
Copilot AI Apr 19, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker run example bind-mounts ./config.json into the container, but it doesn’t mention creating that file first. If config.json doesn’t exist on the host, Docker will typically create a directory at that path and mount it to /app/config.json, causing the app’s config load to fail. Consider adding a short step before the run command (e.g., copy from config.json.example).

Copilot uses AI. Check for mistakes.
chanhanzhan and others added 2 commits April 20, 2026 00:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: chanhanzhan <174212802+chanhanzhan@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: chanhanzhan <174212802+chanhanzhan@users.noreply.github.com>
@chanhanzhan
chanhanzhan merged commit 6c23ffa into XxxXTeam:main May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0