Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
155991fcbc | ||
|
|
1e0f44962f | ||
|
|
9edcc1e9c9 | ||
|
|
b543857595 | ||
|
|
32f2065446 | ||
|
|
bb01daeb4d | ||
|
|
69591ec230 | ||
|
|
f7ebfffddb | ||
|
|
cdaf343fc0 |
@@ -2,6 +2,8 @@ name: docker-node image
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- docker-node/**
|
||||
schedule:
|
||||
- cron: '0 0 * * 0' # 00:00 sáng Chủ nhật (UTC)
|
||||
workflow_dispatch: # Cho phép chạy tay nếu cần
|
||||
@@ -34,11 +36,11 @@ jobs:
|
||||
echo "Building image ${{ env.IMAGE }} for architecture: ${{ matrix.arch }}"
|
||||
|
||||
docker build \
|
||||
-f ${{ env.IMAGE }}.Dockerfile \
|
||||
-f ${{ env.IMAGE }}/Dockerfile \
|
||||
-t ${{ env.IMAGE_BASE }}:${{ env.IMAGE }}-${{ matrix.arch }}-latest \
|
||||
--label "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
|
||||
--label "commit_sha=${{ github.sha }}" \
|
||||
.
|
||||
${{ env.IMAGE }}
|
||||
|
||||
docker push ${{ env.IMAGE_BASE }}:${{ env.IMAGE }}-${{ matrix.arch }}-latest
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
name: node-go image
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- node-go/**
|
||||
schedule:
|
||||
- cron: '0 2 * * 0' # 02:00 sáng Chủ nhật (UTC)
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
IMAGE_REPO: git.thuanle.me/public/node-go
|
||||
IMAGE: node-go
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- arm64
|
||||
- amd64
|
||||
runs-on: ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.thuanle.me
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build Docker images
|
||||
run: |
|
||||
echo "Building image ${{ env.IMAGE }} for architecture: ${{ matrix.arch }}"
|
||||
|
||||
docker build \
|
||||
-f ${{ env.IMAGE }}/Dockerfile \
|
||||
-t ${{ env.IMAGE_REPO }}:${{ matrix.arch }}-latest \
|
||||
--label "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
|
||||
--label "commit_sha=${{ github.sha }}" \
|
||||
${{ env.IMAGE }}
|
||||
|
||||
docker push ${{ env.IMAGE_REPO }}:${{ matrix.arch }}-latest
|
||||
|
||||
amend-manifest:
|
||||
runs-on: linux
|
||||
needs: [build]
|
||||
steps:
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.thuanle.me
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Push Docker manifest
|
||||
run: |
|
||||
echo "Delete existing manifest"
|
||||
docker manifest rm ${{ env.IMAGE_REPO }}:latest || true
|
||||
|
||||
echo "Create new manifest"
|
||||
docker manifest create ${{ env.IMAGE_REPO }}:latest \
|
||||
${{ env.IMAGE_REPO }}:amd64-latest \
|
||||
${{ env.IMAGE_REPO }}:arm64-latest
|
||||
|
||||
docker manifest push ${{ env.IMAGE_REPO }}:latest
|
||||
@@ -2,6 +2,8 @@ name: node-python image
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- node-python/**
|
||||
schedule:
|
||||
- cron: '0 1 * * 0' # 01:00 sáng Chủ nhật (UTC)
|
||||
workflow_dispatch: # Cho phép chạy tay nếu cần
|
||||
@@ -34,11 +36,11 @@ jobs:
|
||||
echo "Building image ${{ env.IMAGE }} for architecture: ${{ matrix.arch }}"
|
||||
|
||||
docker build \
|
||||
-f ${{ env.IMAGE }}.Dockerfile \
|
||||
-f ${{ env.IMAGE }}/Dockerfile \
|
||||
-t ${{ env.IMAGE_BASE }}:${{ env.IMAGE }}-${{ matrix.arch }}-latest \
|
||||
--label "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
|
||||
--label "commit_sha=${{ github.sha }}" \
|
||||
.
|
||||
${{ env.IMAGE }}
|
||||
|
||||
docker push ${{ env.IMAGE_BASE }}:${{ env.IMAGE }}-${{ matrix.arch }}-latest
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Kho lưu trữ này cung cấp các Docker base image cho nhiều mục đích s
|
||||
|
||||
- **docker-node**
|
||||
- `git.thuanle.me/public/base:docker-node-latest`
|
||||
- Dockerfile: [docker-node.Dockerfile](docker-node.Dockerfile)
|
||||
- Dockerfile: [docker-node/Dockerfile](docker-node/Dockerfile)
|
||||
- Các gói/phần mềm đã cài đặt:
|
||||
- **Node.js v22** kèm theo **npm** và **yarn**
|
||||
- **Docker CLI**
|
||||
@@ -14,12 +14,24 @@ Kho lưu trữ này cung cấp các Docker base image cho nhiều mục đích s
|
||||
|
||||
- **node-python**
|
||||
- `git.thuanle.me/public/base:node-python-latest`
|
||||
- Dockerfile: [node-python.Dockerfile](node-python.Dockerfile)
|
||||
- Dockerfile: [node-python/Dockerfile](node-python/Dockerfile)
|
||||
- Các gói/phần mềm đã cài đặt:
|
||||
- **Node.js** kèm theo **npm** và **yarn**
|
||||
- **git**
|
||||
- **python v3.11**
|
||||
|
||||
- **node-go**
|
||||
- `git.thuanle.me/public/node-go:latest`
|
||||
- Dockerfile: [node-go/Dockerfile](node-go/Dockerfile)
|
||||
- Workflow: [.gitea/workflows/node-go.yml](.gitea/workflows/node-go.yml)
|
||||
- Các gói/phần mềm đã cài đặt:
|
||||
- **Node.js** kèm theo **npm** và **yarn**
|
||||
- **git**
|
||||
- **Go 1.26**
|
||||
- **golangci-lint v2.12.2**
|
||||
- Ghi chú:
|
||||
- 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
|
||||
|
||||
- Repo được update hàng tuần.
|
||||
@@ -0,0 +1,33 @@
|
||||
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}
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends ca-certificates curl git gcc libc6-dev; \
|
||||
arch="$(dpkg --print-architecture)"; \
|
||||
case "${arch}" in \
|
||||
amd64) go_arch='linux-amd64' ;; \
|
||||
arm64) go_arch='linux-arm64' ;; \
|
||||
*) echo "Unsupported architecture: ${arch}" >&2; exit 1 ;; \
|
||||
esac; \
|
||||
case "${GO_VERSION}" in \
|
||||
*.*.*) download_go_version="${GO_VERSION}" ;; \
|
||||
*.*) download_go_version="${GO_VERSION}.0" ;; \
|
||||
*) echo "GO_VERSION must be major.minor or major.minor.patch: ${GO_VERSION}" >&2; exit 1 ;; \
|
||||
esac; \
|
||||
curl -fsSL "https://go.dev/dl/go${download_go_version}.${go_arch}.tar.gz" -o /tmp/go.tgz; \
|
||||
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
|
||||
@@ -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 ...@<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` 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.
|
||||
+34
-1
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user