Skip to content

chore: update Docker configuration#425

Closed
dqbpqdpb wants to merge 1 commit intorouter-for-me:mainfrom
dqbpqdpb:update-docker-20260310
Closed

chore: update Docker configuration#425
dqbpqdpb wants to merge 1 commit intorouter-for-me:mainfrom
dqbpqdpb:update-docker-20260310

Conversation

@dqbpqdpb
Copy link

Summary

Update Docker configuration with latest versions and best practices.

Changes

  • Upgrade Alpine from 3.22.0 to 3.23.3 (security fixes for OpenSSL)
  • Add multi-platform build support (ARM64, ARM, x86)
  • Add Go module caching for faster builds (--mount=type=cache)
  • Add non-root user for security
  • Add health check configuration in both Dockerfile and docker-compose
  • Add resource limits in docker-compose (CPU/memory)
  • Add logging configuration with rotation (max-size: 10m, max-file: 3)
  • Add ca-certificates for HTTPS support
  • Add volume mount as read-only for config file

Breaking Changes

None - these are backward compatible improvements.

…tices

- Upgrade Alpine from 3.22.0 to 3.23.3 (security fixes)
- Add multi-platform build support (ARM64, ARM, x86)
- Add Go module caching for faster builds
- Add non-root user for security
- Add health check configuration
- Add resource limits in docker-compose
- Add logging configuration with rotation
- Add ca-certificates for HTTPS support
- Add volume mount as read-only for config
@dqbpqdpb dqbpqdpb closed this by deleting the head repository Mar 10, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Docker configuration for the application, focusing on security, performance, and operational robustness. It updates the base image to a more secure version, enables multi-platform builds, and introduces build optimizations. Furthermore, it strengthens container security by adopting a non-root user and read-only mounts, while also improving deployability and monitoring through integrated health checks, resource limits, and structured logging.

Highlights

  • Alpine Upgrade: Upgraded the base Alpine image from 3.22.0 to 3.23.3, addressing security vulnerabilities, particularly in OpenSSL.
  • Multi-Platform Builds: Introduced support for multi-platform Docker builds, including ARM64, ARM, and x86 architectures.
  • Go Module Caching: Implemented Go module caching during the build process to significantly speed up subsequent builds.
  • Non-Root User: Added a dedicated non-root user (appuser) for running the application within the container, enhancing security.
  • Health Checks: Integrated health check configurations into both the Dockerfile and docker-compose.yml to monitor application readiness.
  • Resource Limits: Configured CPU and memory resource limits and reservations in docker-compose.yml for better resource management.
  • Logging Configuration: Added logging configuration with rotation (max-size: 10m, max-file: 3) to docker-compose.yml for improved log management.
  • HTTPS Support: Included ca-certificates in the final image to ensure proper HTTPS communication.
  • Read-Only Volume Mount: Set the configuration file volume mount as read-only in docker-compose.yml for enhanced security.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • Dockerfile
    • Updated the base Alpine image from 3.22.0 to 3.23.3.
    • Modified the FROM instruction to support multi-platform builds using $BUILDPLATFORM.
    • Added git and make to the builder stage.
    • Implemented Go module caching using --mount=type=cache for go mod download.
    • Introduced TARGETOS and TARGETARCH arguments for cross-compilation.
    • Created a non-root user appuser and group appgroup.
    • Added ca-certificates to the final image.
    • Set ownership of /CLIProxyAPI to appuser:appgroup.
    • Copied application binary and config file with chown to appuser:appgroup.
    • Switched the container user to appuser.
    • Expanded the list of exposed ports.
    • Added a HEALTHCHECK instruction using wget.
  • docker-compose.yml
    • Added TZ environment variable to the service.
    • Modified the config.yaml volume mount to be read-only (:ro).
    • Introduced a healthcheck block with test, interval, timeout, retries, and start_period configurations.
    • Added a deploy.resources block to define limits and reservations for CPU and memory.
    • Configured logging with json-file driver and max-size/max-file options.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces several improvements to the Docker build process and deployment configuration. Key changes include enabling multi-platform builds, adding a non-root user (appuser) for enhanced security, and configuring a health check for the Docker image. Additionally, the docker-compose.yml has been updated to include a health check, resource limits, and logging configurations, and to mount the application configuration as read-only. Review comments highlight critical issues: the TARGETOS and TARGETARCH variables in the Dockerfile are incorrectly defined as shell variables instead of ARG instructions, the wget command used in the Dockerfile's health check is missing from the image, the timezone setting command in the Dockerfile runs after switching to a non-root user causing permission errors, and the docker-compose.yml mounts authentication tokens to /root which is inaccessible by the new appuser, breaking authentication.

Comment on lines +17 to +18
TARGETOS=${TARGETOS:-linux}
TARGETARCH=${TARGETARCH:-amd64}

Choose a reason for hiding this comment

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

critical

These lines use shell syntax (VAR=${VAR:-default}) which is not a valid Dockerfile instruction for defining build arguments. To define build-time arguments with default values, you should use the ARG instruction. For multi-platform builds with buildx, TARGETOS and TARGETARCH are automatically populated, and using ARG will correctly receive them.

ARG TARGETOS=linux
ARG TARGETARCH=amd64

Comment on lines +26 to +31
RUN addgroup -g 1000 appgroup && \
adduser -u 1000 -G appgroup -s /bin/sh -D appuser

RUN mkdir /CLIProxyAPI
RUN apk add --no-cache tzdata ca-certificates

COPY --from=builder ./app/CLIProxyAPIPlus /CLIProxyAPI/CLIProxyAPIPlus
RUN mkdir -p /CLIProxyAPI && chown -R appuser:appgroup /CLIProxyAPI

Choose a reason for hiding this comment

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

critical

The HEALTHCHECK instruction on line 46 uses wget, but it is not installed in the final image. This will cause the health check to fail. You should add wget to the package installation.

Additionally, to reduce image layers and improve build efficiency, it's best to combine related RUN commands into a single instruction.

RUN addgroup -g 1000 appgroup && \
    adduser -u 1000 -G appgroup -s /bin/sh -D appuser && \
    apk add --no-cache tzdata ca-certificates wget && \
    mkdir -p /CLIProxyAPI && chown -R appuser:appgroup /CLIProxyAPI

volumes:
- ${CLI_PROXY_CONFIG_PATH:-./config.yaml}:/CLIProxyAPI/config.yaml
- ${CLI_PROXY_CONFIG_PATH:-./config.yaml}:/CLIProxyAPI/config.yaml:ro
- ${CLI_PROXY_AUTH_PATH:-./auths}:/root/.cli-proxy-api

Choose a reason for hiding this comment

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

security-medium medium

The volume for authentication tokens is mounted to /root/.cli-proxy-api. Since the container now runs as the non-root user appuser, and the application expects tokens in the user's home directory (defaulting to ~/.cli-proxy-api), the application will be unable to access the mounted tokens due to permission restrictions on the /root directory. This breaks the intended security model, may lead users to revert to running as root, and will cause authentication data to be non-persistent. Please update the mount path to the correct directory for appuser.

       - ${CLI_PROXY_AUTH_PATH:-./auths}:/home/appuser/.cli-proxy-api

EXPOSE 8317 8085 1455 54545 51121 11451

ENV TZ=Asia/Shanghai
RUN cp /usr/share/zoneinfo/${TZ} /etc/localtime && echo "${TZ}" > /etc/timezone

Choose a reason for hiding this comment

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

security-medium medium

The RUN command to set the timezone is executed after switching to the non-root user appuser. This will cause the build to fail because appuser does not have permission to write to /etc/localtime and /etc/timezone. Move these commands before the USER appuser instruction.

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.

1 participant