From 155991fcbc1d14fef202b2cdedf555c766a22280 Mon Sep 17 00:00:00 2001 From: thuanle Date: Tue, 11 Aug 2026 15:20:24 +0700 Subject: [PATCH] feat(node-go): add golangci-lint + Renovate auto-bump - Add golangci-lint v2.12.2 to node-go image (arch-aware via official install.sh) - Wire renovate.json to auto-bump GOLANGCI_LINT_VERSION (minor/patch automerge) and GO_VERSION (patch automerge); keep pins for reproducible/rollback-able builds - Add node-go/README.md documenting installed tools and what's NOT included - Update root README accordingly Co-Authored-By: Claude --- README.md | 3 +- node-go/Dockerfile | 5 +++ node-go/README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++ renovate.json | 35 ++++++++++++++++++++- 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 node-go/README.md diff --git a/README.md b/README.md index 491fea9..519b276 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,9 @@ Kho lưu trữ này cung cấp các Docker base image cho nhiều mục đích s - **Node.js** kèm theo **npm** và **yarn** - **git** - **Go 1.26** + - **golangci-lint v2.12.2** - Ghi chú: - - `GO_VERSION` hiện được giữ ở mức `1.26` và sẽ nâng thủ công khi cần + - Phiên bản (`GO_VERSION`, `GOLANGCI_LINT_VERSION`) được pin trong Dockerfile; [Renovate](renovate.json) tự bump qua PR khi có release mới (auto-merge minor/patch) ## Update diff --git a/node-go/Dockerfile b/node-go/Dockerfile index c9ee2f7..6716eca 100644 --- a/node-go/Dockerfile +++ b/node-go/Dockerfile @@ -1,6 +1,7 @@ FROM node:lts-slim ARG GO_VERSION=1.26 +ARG GOLANGCI_LINT_VERSION=v2.12.2 ENV DEBIAN_FRONTEND=noninteractive \ PATH=/usr/local/go/bin:${PATH} @@ -23,6 +24,10 @@ RUN set -eux; \ rm -rf /usr/local/go; \ tar -C /usr/local -xzf /tmp/go.tgz; \ rm -f /tmp/go.tgz; \ + curl -fsSL -o /tmp/golangci-lint-install.sh \ + "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh"; \ + sh /tmp/golangci-lint-install.sh -b /usr/local/bin "${GOLANGCI_LINT_VERSION}"; \ + rm -f /tmp/golangci-lint-install.sh; \ rm -rf /var/lib/apt/lists/* WORKDIR /app diff --git a/node-go/README.md b/node-go/README.md new file mode 100644 index 0000000..f4ff7bc --- /dev/null +++ b/node-go/README.md @@ -0,0 +1,76 @@ +# node-go + +Docker base image gồm **Node.js** + **Go** + công cụ lint, dùng làm môi trường +build/test cho CI. + +- Image: `git.thuanle.me/public/node-go:latest` +- Dockerfile: [Dockerfile](Dockerfile) +- Workflow: [`.gitea/workflows/node-go.yml`](../.gitea/workflows/node-go.yml) + +## Kiến trúc được hỗ trợ + +- `linux/amd64` +- `linux/arm64` + +Image được build song song cho cả hai kiến trúc rồi gộp vào một multi-arch +manifest, kéo bằng `:latest` sẽ tự nhận đúng kiến trúc của host. + +## Đã cài đặt sẵn + +| Phần mềm | Phiên bản | Ghi chú | +|---|---|---| +| Node.js | LTS (cùng phiên bản với `node:lts-slim`) | kèm **npm** và **yarn** | +| Go | `1.26` | cài nhị phân chính thức từ `go.dev`, đặt tại `/usr/local/go` | +| golangci-lint | `v2.12.2` | cài vào `/usr/local/bin`, dùng cho `go lint`/CI | +| git | (apt) | | +| gcc + libc6-dev | (apt) | cần cho **cgo** và một số package Go build bằng C | +| ca-certificates, curl | (apt) | | + +> Các phiên bản Go/golangci-lint được **pin bằng `ARG`** trong Dockerfile +> (`GO_VERSION`, `GOLANGCI_LINT_VERSION`) để build ổn định & rollback được, đồng +> thời **[Renovate](../renovate.json) tự bump** qua PR khi có release mới: +> - golangci-lint: auto-merge **minor/patch** (major vd v2→v3 mở PR review). +> - Go: auto-merge **patch**; minor (vd 1.26→1.27) mở PR review. + +## Cách sử dụng + +```yaml +# .gitea/workflows/... +container: + image: git.thuanle.me/public/node-go:latest +steps: + - run: node -v && go version && golangci-lint version + - run: golangci-lint run ./... + - run: go test ./... +``` + +Hoặc chạy cục bộ: + +```bash +docker run --rm git.thuanle.me/public/node-go:latest \ + sh -c "go version && golangci-lint version" +``` + +## Những gì KHÔNG có (có thể cần cài thêm) + +Image này cố gắng nhỏ gọn, nên một số thứ sau **không** được cài sẵn — cài thêm +trong CI/Dockerfile của dự án nếu cần: + +- **Docker CLI** — nếu cần build/push image, dùng image + [`docker-node`](../docker-node) thay thế. +- **Python** — dùng image [`node-python`](../node-python). +- **Make**, **jq**, **zip/unzip**, **openssh-client**… — `apt-get install` trong + pipeline khi cần. +- **Các Go tool cụ thể của dự án** (vd: `mockgen`, `protoc-gen-go`, + `wire`…) — `go install ...@` trong bước CI, vì mỗi dự án cần + phiên bản khác nhau. +- **Hồ sơ Git (user.name/user.email)** — tự cấu hình trong CI. + +## Nâng cấp + +- **Tự động (mặc định)**: [Renovate](../renovate.json) theo dõi `GO_VERSION` và + `GOLANGCI_LINT_VERSION`, tự mở PR (và auto-merge theo quy tắc ở trên) khi có + release mới. PR merge → workflow build lại image. +- **Thủ công** (khi cần bump major, vd golangci-lint v2→v3 hoặc Go 1.26→1.27): + sửa trực tiếp `ARG` trong [Dockerfile](Dockerfile) rồi push. +- Image cũng được build lại hàng tuần theo lịch (`cron`) trong workflow. diff --git a/renovate.json b/renovate.json index 7190a60..4f136f1 100644 --- a/renovate.json +++ b/renovate.json @@ -1,3 +1,36 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json" + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "customManagers": [ + { + "customType": "regex", + "description": "Bump golangci-lint version ARG trong node-go/Dockerfile", + "fileMatch": ["node-go/Dockerfile$"], + "matchStrings": ["ARG GOLANGCI_LINT_VERSION=(?\\S+)"], + "datasourceTemplate": "github-releases", + "depNameTemplate": "golangci/golangci-lint" + }, + { + "customType": "regex", + "description": "Bump Go version ARG trong node-go/Dockerfile", + "fileMatch": ["node-go/Dockerfile$"], + "matchStrings": ["ARG GO_VERSION=(?\\S+)"], + "datasourceTemplate": "golang-version", + "depNameTemplate": "go" + } + ], + "packageRules": [ + { + "description": "golangci-lint: auto-merge minor/patch, major (vd v2->v3) can review", + "matchDatasources": ["github-releases"], + "matchPackageNames": ["golangci/golangci-lint"], + "matchUpdateTypes": ["minor", "patch"], + "automerge": true + }, + { + "description": "Go: chi auto-merge patch; minor (vd 1.26->1.27) can review thu cong", + "matchDatasources": ["golang-version"], + "matchUpdateTypes": ["patch"], + "automerge": true + } + ] }