feat(node-go): thêm golangci-lint + Renovate auto-bump #3

Merged
thuanle merged 1 commits from feat/node-go-golangci-lint into main 2026-08-11 15:22:29 +07:00
4 changed files with 117 additions and 2 deletions
Showing only changes of commit 155991fcbc - Show all commits
+2 -1
View File
@@ -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****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
+5
View File
@@ -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
+76
View File
@@ -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****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 ...@<version>` 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`
`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.
+34 -1
View File
@@ -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=(?<currentValue>\\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=(?<currentValue>\\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
}
]
}