Skip to content

Commit 7721230

Browse files
committed
Merge remote-tracking branch 'origin/master' into pgstattuple-collector
2 parents d3d1728 + 2e4c57f commit 7721230

41 files changed

Lines changed: 2485 additions & 125 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/beta.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
jobs:
2121
test:
2222
runs-on: ubuntu-22.04
23-
container: cherts/pgscv-test-runner:1.0.10
23+
container: cherts/pgscv-test-runner:2.0.12
2424
steps:
2525
- name: Checkout code
2626
uses: actions/checkout@v5
@@ -35,6 +35,11 @@ jobs:
3535
permissions:
3636
contents: read
3737
packages: write
38+
id-token: write
39+
attestations: write
40+
env:
41+
REGISTRY: ghcr.io
42+
IMAGE_NAME: ${{ github.repository }}
3843
steps:
3944
- name: Checkout code
4045
uses: actions/checkout@v5
@@ -50,17 +55,41 @@ jobs:
5055
- name: Login to registry
5156
uses: docker/login-action@v3
5257
with:
53-
registry: ghcr.io
58+
registry: ${{ env.REGISTRY }}
5459
username: ${{ github.actor }}
5560
password: ${{ secrets.GITHUB_TOKEN }}
61+
- name: Set up Docker meta
62+
id: meta
63+
uses: docker/metadata-action@v5
64+
with:
65+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
66+
tags: |
67+
type=raw,value=v${{ steps.version.outputs.VERSION }}-${{ steps.version.outputs.GIT_BRANCH }}-${{ steps.version.outputs.GIT_COMMIT }}-${{ steps.version.outputs.GIT_DATE }}-beta
5668
- name: Set up QEMU
5769
uses: docker/setup-qemu-action@v3
5870
- name: Set up Docker Buildx
5971
uses: docker/setup-buildx-action@v3
6072
- name: Build and push
73+
id: push
6174
uses: docker/build-push-action@v6
6275
with:
6376
context: .
77+
file: ./Dockerfile.beta
6478
platforms: linux/amd64
6579
push: true
66-
tags: ghcr.io/${{ github.repository_owner }}:v${{ steps.version.outputs.VERSION }}-${{ steps.version.outputs.GIT_BRANCH }}-${{ steps.version.outputs.GIT_COMMIT }}-${{ steps.version.outputs.GIT_DATE }}-beta
80+
tags: ${{ steps.meta.outputs.tags }}
81+
- name: Generate artifact attestation
82+
uses: actions/attest-build-provenance@v3
83+
id: attest
84+
with:
85+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
86+
subject-digest: ${{ steps.push.outputs.digest }}
87+
push-to-registry: true
88+
- name: Cleanup registry
89+
uses: actions/delete-package-versions@v5
90+
with:
91+
owner: ${{ github.repository_owner }}
92+
package-name: 'pgscv'
93+
package-type: container
94+
min-versions-to-keep: 50
95+
# delete-only-untagged-versions: 'true'

.github/workflows/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323
jobs:
2424
test:
2525
runs-on: ubuntu-22.04
26-
container: cherts/pgscv-test-runner:1.0.10
26+
container: cherts/pgscv-test-runner:2.0.12
2727

2828
steps:
2929
- name: Checkout code

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
test:
1212
runs-on: ubuntu-22.04
13-
container: cherts/pgscv-test-runner:1.0.10
13+
container: cherts/pgscv-test-runner:2.0.12
1414
steps:
1515
- name: Checkout code
1616
uses: actions/checkout@v5
@@ -27,11 +27,15 @@ jobs:
2727
uses: actions/checkout@v5
2828
with:
2929
fetch-depth: 0
30+
- name: Lint Dockerfile
31+
run: make docker-lint
3032
- name: Build image
3133
run: make docker-build
3234
- name: Log in to Docker Hub
35+
if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
3336
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
3437
- name: Push image to Docker Hub
38+
if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
3539
run: make docker-push
3640

3741
goreleaser:
@@ -45,7 +49,7 @@ jobs:
4549
- name: Run setup Go
4650
uses: actions/setup-go@v6
4751
with:
48-
go-version: 1.24
52+
go-version: 1.25
4953
- name: Run GoReleaser
5054
uses: goreleaser/goreleaser-action@v6
5155
with:

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stage 1
2-
# __release_tag__ golang 1.24 was released 2025-02-11
3-
FROM golang:1.24 AS build
2+
# __release_tag__ golang 1.25 was released 2025-08-12
3+
FROM golang:1.25 AS build
44
LABEL stage=intermediate
55
WORKDIR /app
66
COPY . .

Dockerfile.beta

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# stage 1
2+
# __release_tag__ golang 1.25 was released 2025-08-12
3+
FROM golang:1.25 AS build
4+
LABEL stage=intermediate
5+
WORKDIR /app
6+
COPY . .
7+
RUN make build-beta
8+
9+
# stage 2: scratch
10+
# __release_tag__ alpine 3.22.0 was released 2025-05-30
11+
LABEL org.opencontainers.image.title="pgSCV"
12+
LABEL org.opencontainers.image.description="pgSCV is a PostgreSQL ecosystem metrics collector"
13+
LABEL org.opencontainers.image.vendor="pgSCV Team"
14+
FROM alpine:3.22.0 AS dist
15+
COPY --from=build /app/bin/pgscv /bin/pgscv
16+
#COPY docker_entrypoint.sh /bin/
17+
EXPOSE 9890
18+
#EXPOSE 6060
19+
ENTRYPOINT ["/bin/pgscv"]
20+
#ENTRYPOINT ["/bin/docker_entrypoint.sh"]

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
2727
VERSION_BETA=1.0-$(BRANCH)-$(COMMIT)-$(DATE)-beta
2828

2929
LDFLAGS = -a -installsuffix cgo -ldflags "-X main.appName=${APPNAME} -X main.gitTag=${VERSION} -X main.gitCommit=${COMMIT} -X main.gitBranch=${BRANCH}"
30+
LDFLAGS_BETA = -a -installsuffix cgo -ldflags "-X main.appName=${APPNAME} -X main.gitTag=${VERSION_BETA} -X main.gitCommit=${COMMIT} -X main.gitBranch=${BRANCH}"
31+
3032
MODERNIZE_CMD = go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.18.1
3133

3234
.PHONY: help \
3335
clean lint test race \
34-
build docker-build docker-push go-update \
36+
build docker-lint docker-build docker-push go-update \
3537
modernize modernize-fix modernize-check
3638

3739
.DEFAULT_GOAL := help
@@ -71,6 +73,15 @@ build: dep ## Build
7173
mkdir -p ./bin
7274
CGO_ENABLED=0 GOOS=${APPOS} GOARCH=${GOARCH} go build ${LDFLAGS} -o bin/${APPNAME} ./cmd
7375

76+
build-beta: dep ## Build beta
77+
mkdir -p ./bin
78+
CGO_ENABLED=0 GOOS=${APPOS} GOARCH=${GOARCH} go build ${LDFLAGS_BETA} -o bin/${APPNAME} ./cmd
79+
80+
docker-lint: ## Lint Dockerfile
81+
@echo "Lint container Dockerfile"
82+
docker run --rm -i -v $(PWD)/Dockerfile:/Dockerfile \
83+
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 /Dockerfile
84+
7485
docker-build: ## Build docker image
7586
docker build -t ${DOCKER_ACCOUNT}/${APPNAME}:${TAG} .
7687
docker image prune --force --filter label=stage=intermediate

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This project is a continuation of the development of the original pgSCV by [Alex
3939
Download the archive from [releases](https://github.com/cherts/pgscv/releases). Unpack the archive. Create minimum config file. Start pgSCV systemd service under `postgres` user.
4040

4141
```bash
42-
curl -s -L https://github.com/cherts/pgscv/releases/download/v0.15.0/pgscv_0.15.0_linux_$(uname -m).tar.gz -o - | tar xzf - -C /tmp && \
42+
curl -s -L https://github.com/cherts/pgscv/releases/download/v1.0.0/pgscv_1.0.0_linux_$(uname -m).tar.gz -o - | tar xzf - -C /tmp && \
4343
mv /tmp/pgscv.yaml /etc && \
4444
mv /tmp/pgscv.service /etc/systemd/system && \
4545
mv /tmp/pgscv.default /etc/default/pgscv && \
@@ -118,6 +118,10 @@ To help development you are encouraged to:
118118
- pull requests for new features
119119
- star the project
120120

121+
### Star History
122+
123+
[![Star History Chart](https://api.star-history.com/svg?repos=cherts/pgscv&type=Date)](https://www.star-history.com/#cherts/pgscv&Date)
124+
121125
### Current developer and maintaner
122126
- [Mikhail Grigorev](https://github.com/cherts)
123127

README.ru.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Загрузите архив со страницы [releases](https://github.com/cherts/pgscv/releases). Распакуйте архив. Создайте минимальный файл конфигураации. Запустите pgSCV под пользователем postgres.
3333

3434
```bash
35-
curl -s -L https://github.com/cherts/pgscv/releases/download/v0.15.0/pgscv_0.15.0_linux_$(uname -m).tar.gz -o - | tar xzf - -C /tmp && \
35+
curl -s -L https://github.com/cherts/pgscv/releases/download/v1.0.0/pgscv_1.0.0_linux_$(uname -m).tar.gz -o - | tar xzf - -C /tmp && \
3636
mv /tmp/pgscv.yaml /etc && \
3737
mv /tmp/pgscv.service /etc/systemd/system && \
3838
mv /tmp/pgscv.default /etc/default/pgscv && \
@@ -111,6 +111,10 @@ helm install -n pgscv-ns pgscv deploy/helm-chart/
111111
- запросить новую функциональность;
112112
- поставить звезду проекту на Github;
113113

114+
### История звезд
115+
116+
[![Star History Chart](https://api.star-history.com/svg?repos=cherts/pgscv&type=Date)](https://www.star-history.com/#cherts/pgscv&Date)
117+
114118
### Текущий разработчик и сопровождающий
115119
- [Mikhail Grigorev](https://github.com/cherts)
116120

deploy/pgscv.yaml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,58 @@
3030
# postgres/stattuple:
3131
# ttl: 24h
3232
#discovery:
33+
# Monitoring local PostgreSQL on macOS (https://postgresapp.com)
34+
# local_macos_postgresapp:
35+
# type: script
36+
# config:
37+
# script: discovery-scripts/example-postgresapp-macos-discovery.sh
38+
# execution_timeout: 10s
39+
# refresh_interval: 5m
40+
# args:
41+
# - "ALL"
42+
# env:
43+
# - name: PG_PASSWORD
44+
# value: "pgscv"
45+
# debug: false
46+
# target_labels:
47+
# - name: environment
48+
# value: "local"
49+
# - name: __scrape_interval__
50+
# value: 1m
51+
#
52+
# Monitoring AWS RDS PostgreSQL
53+
# aws:
54+
# type: script
55+
# config:
56+
# script: discovery-scripts/example-aws-discovery.sh
57+
# execution_timeout: 30s
58+
# refresh_interval: 5m
59+
# args:
60+
# - "--profile=default --region=us-west-1"
61+
# env:
62+
# - name: PG_PASSWORD
63+
# value: "pgscv"
64+
# - name: AWS_ACCESS_KEY_ID
65+
# value: "EXAMPLE"
66+
# - name: AWS_SECRET_ACCESS_KEY
67+
# value: "XXX/YYY/ZZZ"
68+
# debug: false
69+
# target_labels:
70+
# - name: environment
71+
# value: "production"
72+
# - name: region
73+
# value: "us-west-1"
74+
# - name: __scrape_interval__
75+
# value: 1m
3376
# Monitoring Yandex.Cloud Managed Service for PostgreSQL
3477
# yandex_mdb:
3578
# type: yandex-mdb
3679
# config:
3780
# - authorized_key: /path/to/secret/authorized_key.json
3881
# folder_id: "b1000000000000"
82+
# user: "pgscv"
3983
# password: "password"
40-
# password_from_env: DB_PASSWORD
41-
# user: "postgres_exporter"
84+
# #password_from_env: DB_PASSWORD
4285
# refresh_interval: 5
4386
# clusters:
4487
# - name: ".*"

0 commit comments

Comments
 (0)