Skip to content

perf: optimize docker build#39

Merged
lethanhdat762003 merged 1 commit into
devfrom
perf/optimize-docker-build
Jun 29, 2026
Merged

perf: optimize docker build#39
lethanhdat762003 merged 1 commit into
devfrom
perf/optimize-docker-build

Conversation

@lethanhdat762003

Copy link
Copy Markdown
Member

What?

Why?

How?

Testing?

  • Functional Testing
  • Security
  • Performance
  • Error Handling
  • Code Quality
  • Documentation
  • Database
  • Deployment
  • Final Review

Anything Else?

@lethanhdat762003
lethanhdat762003 changed the base branch from main to dev June 29, 2026 14:10
@claude

claude Bot commented Jun 29, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@lethanhdat762003
lethanhdat762003 merged commit 3b71a91 into dev Jun 29, 2026
1 of 2 checks passed

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Dockerfile to use the BuildKit syntax directive and introduces cache mounts for Go modules and Go builds to optimize build performance. The feedback recommends pinning the Dockerfile syntax to the major version (1) rather than a specific minor version to receive automatic updates, and adding unique IDs to the cache mounts to prevent cache thrashing in shared CI/CD environments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread Dockerfile
@@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.7

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a specific minor version like 1.7 for the Dockerfile syntax directive prevents the build from automatically receiving security updates, bug fixes, and performance improvements. It is highly recommended to use # syntax=docker/dockerfile:1 to pin to the major version 1, which automatically resolves to the latest stable minor release while maintaining backward compatibility.

# syntax=docker/dockerfile:1

Comment thread Dockerfile
Comment on lines +12 to +13
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

When using --mount=type=cache without a unique id, the cache is shared globally across all builds on the same runner that use the same target path. In a shared CI/CD environment with multiple Go projects, this can lead to cache thrashing and frequent evictions. Specifying a unique id (e.g., id=mpa-service-go-mod) ensures that this project's module cache is isolated and preserved.

RUN --mount=type=cache,id=mpa-service-go-mod,target=/go/pkg/mod \
    go mod download

Comment thread Dockerfile
Comment on lines +23 to +25
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To ensure cache isolation and prevent cache thrashing in shared CI/CD environments, specify unique ids for both the Go module cache and the Go build cache mounts. This ensures that the caches are dedicated to this project and not overwritten or evicted by other Go builds on the same runner.

RUN --mount=type=cache,id=mpa-service-go-mod,target=/go/pkg/mod \
    --mount=type=cache,id=mpa-service-go-build,target=/root/.cache/go-build \
    CGO_ENABLED=0 \

@ngovinh2k2
ngovinh2k2 deleted the perf/optimize-docker-build branch July 3, 2026 08:12
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