Skip to content

Commit 47bc437

Browse files
authored
chore: Bump alpine to 3.21 (#279)
* chore: Bump alpine to 3.21 * chore: Remove go patch version from go.mod * refactor: Scripts * chore: Remove go patch version form go mod * docs: Update readme
1 parent 5372434 commit 47bc437

File tree

57 files changed

+500
-409
lines changed

Some content is hidden

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

57 files changed

+500
-409
lines changed

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.23.4-alpine3.20 AS builder
1+
FROM --platform=$BUILDPLATFORM golang:1.23.4-alpine3.21 AS builder
22

33
ARG APK_BASH_VERSION=~5
44
ARG APK_GIT_VERSION=~2
55
ARG APK_MAKE_VERSION=~4
66
ARG APK_OPENSSH_VERSION=~9
7-
ARG APK_GCC_VERSION=~13
7+
ARG APK_GCC_VERSION=~14
88
ARG APK_BUILDBASE_VERSION=~0
9-
ARG APK_CA_CERTIFICATES_VERSION=20240705-r0
9+
ARG APK_CA_CERTIFICATES_VERSION=20241010-r0
1010
ARG APK_BINUTILS_VERSION=~2
1111

1212
RUN apk add --no-cache \
@@ -41,12 +41,12 @@ RUN --mount=type=bind,source=./scripts,target=./scripts \
4141
GOOS=$TARGETOS GOARCH=$TARGETARCH make install-tools
4242

4343

44-
FROM golang:1.23.4-alpine3.20 AS releaser
44+
FROM golang:1.23.4-alpine3.21 AS releaser
4545

4646
ARG APK_BASH_VERSION=~5
4747
ARG APK_BUILDBASE_VERSION=~0
4848
ARG APK_GIT_VERSION=~2
49-
ARG APK_DOCKER_CLI_VERSION=~26
49+
ARG APK_DOCKER_CLI_VERSION=~27
5050
ARG APK_DOCKER_CLI_COMPOSE_VERSION=~2
5151
ARG APK_DOCKER_CLI_BUILDX_VERSION=~0
5252
ARG APK_OPENSSH_VERSION=~9

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,36 @@ docker pull ghcr.io/obalunenko/go-tools:latest
1515

1616
### Go base image
1717

18-
The base image is built on top of the official image [golang:1.23.1-alpine3.20](https://hub.docker.com/_/golang) and includes the following tools:
18+
The base image is built on top of the official image [golang:1.23.4-alpine3.21](https://hub.docker.com/_/golang) and includes the following tools:
1919

2020

2121
##### Below is a full manifest of the tools available
2222

2323

2424
| Tool | Version | Description |
2525
|------------------------------------------------------------|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
26-
| [go-enum](https://github.com/abice/go-enum) | v0.6.0 | An enum generator for go |
26+
| [buf](https://github.com/bufbuild/buf) | v1.48.0 | The buf CLI is the best tool for working with Protocol Buffers |
27+
| [coverbadger](https://github.com/obalunenko/coverbadger) | v1.4.0 | Generate coverage badge images for Markdown files using Go |
2728
| [enumer](https://github.com/alvaroloes/enumer) | v1.1.2 | A Go tool to auto generate methods for your enums |
28-
| [gocov](https://github.com/axw/gocov) | v1.1.0 | Coverage testing tool for The Go Programming Language |
29-
| [svu](https://github.com/caarlos0/svu) | v2.2.0 | Semantic Version Util |
30-
| [swagger](https://github.com/go-swagger/go-swagger) | v0.31.0 | Client/Server from OpenAPI docs generation tool |
31-
| [golangci-lint](https://github.com/golangci/golangci-lint) | v1.60.3 | Fast linters Runner for Go |
32-
| [goreleaser](https://github.com/goreleaser/goreleaser) | v2.2.0 | Deliver Go binaries as fast and easily as possible |
29+
| [fiximports](https://golang.org/x/tools/cmd/fiximports) | v0.28.0 | The fiximports command fixes import declarations to use the canonical import path for packages that have an "import comment" as defined by https://golang.org/s/go14customimport. |
30+
| [go-enum](https://github.com/abice/go-enum) | v0.6.0 | An enum generator for go |
31+
| [gocov](https://github.com/axw/gocov) | v1.2.1 | Coverage testing tool for The Go Programming Language |
3332
| [gocov-html](https://github.com/matm/gocov-html) | v1.4.0 | Make pretty HTML output from gocov, a coverage testing tool for Go |
34-
| [goveralls](https://github.com/mattn/goveralls) | v0.0.12 | Go integration for Coveralls.io continuous code coverage tracking system. |
35-
| [tparse](https://github.com/mfridman/tparse) | v0.14.0 | CLI tool for summarizing go test output. Pipe friendly. CI/CD friendly. |
36-
| [coverbadger](https://github.com/obalunenko/coverbadger) | v1.4.0 | Generate coverage badge images for Markdown files using Go |
33+
| [gofumpt](https://mvdan.cc/gofumpt) | v0.7.0 | A stricter gofmt |
34+
| [goimports](https://golang.org/x/tools/cmd/goimports) | v0.28.0 | Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones |
35+
| [golangci-lint](https://github.com/golangci/golangci-lint) | v1.62.2 | Fast linters Runner for Go |
36+
| [goose](https://github.com/pressly/goose/v3/cmd/goose) | v3.24.0 | A database migration tool |
3737
| [goreadme](https://github.com/posener/goreadme) | v1.4.2 | Generate readme file from Go doc |
38-
| [goose](https://github.com/pressly/goose/v3/cmd/goose) | v3.22.0 | A database migration tool |
39-
| [swag](github.com/swaggo/swag/cmd/swag) | v1.16.3 | Automatically generate RESTful API documentation with Swagger 2.0 for Go |
40-
| [pkgsite](https://golang.org/x/pkgsite/cmd/pkgsite) | v0.0.0-20240905030440-6b577b411ef5 | Pkgsite extracts and generates documentation for Go programs. It runs as a web server and presents the documentation as a web page. |
41-
| [fiximports](https://golang.org/x/tools/cmd/fiximports) | v0.24.0 | The fiximports command fixes import declarations to use the canonical import path for packages that have an "import comment" as defined by https://golang.org/s/go14customimport. |
42-
| [goimports](https://golang.org/x/tools/cmd/goimports) | v0.24.0 | Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones |
43-
| [stringer](https://golang.org/x/tools/cmd/stringer) | v0.24.0 | Stringer is a tool to automate the creation of methods that satisfy the fmt.Stringer interface. |
44-
| [govulncheck](https://golang.org/x/vuln/cmd/govulncheck) | v1.1.3 | Govulncheck reports known vulnerabilities that affect Go code. |
38+
| [goreleaser](https://github.com/goreleaser/goreleaser) | v2.5.0 | Deliver Go binaries as fast and easily as possible |
4539
| [gotestsum](https://gotest.tools/gotestsum) | v1.12.0 | 'go test' runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results. |
46-
| [gofumpt](https://mvdan.cc/gofumpt) | v0.7.0 | A stricter gofmt |
40+
| [goveralls](https://github.com/mattn/goveralls) | v0.0.12 | Go integration for Coveralls.io continuous code coverage tracking system. |
41+
| [govulncheck](https://golang.org/x/vuln/cmd/govulncheck) | v1.1.3 | Govulncheck reports known vulnerabilities that affect Go code. |
42+
| [pkgsite](https://golang.org/x/pkgsite/cmd/pkgsite) | v0.0.0-20241216215327-06c6edf28e6c | Pkgsite extracts and generates documentation for Go programs. It runs as a web server and presents the documentation as a web page. |
43+
| [stringer](https://golang.org/x/tools/cmd/stringer) | v0.28.0 | Stringer is a tool to automate the creation of methods that satisfy the fmt.Stringer interface. |
44+
| [svu](https://github.com/caarlos0/svu) | v2.2.0 | Semantic Version Util |
45+
| [swag](github.com/swaggo/swag/cmd/swag) | v1.16.4 | Automatically generate RESTful API documentation with Swagger 2.0 for Go |
46+
| [swagger](https://github.com/go-swagger/go-swagger) | v0.31.0 | Client/Server from OpenAPI docs generation tool |
47+
| [tparse](https://github.com/mfridman/tparse) | v0.16.0 | CLI tool for summarizing go test output. Pipe friendly. CI/CD friendly. |
4748

4849

4950
## How to Use

scripts/install/vendored-tools.sh

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,97 @@
11
#!/bin/bash
22

3+
# Enable strict error handling
34
set -eu
45

6+
# Script metadata
57
SCRIPT_NAME="$(basename "$0")"
68
REPO_ROOT="$(pwd)"
79
TOOLS_DIR="${REPO_ROOT}/tools"
810

911
echo "${SCRIPT_NAME} is running... "
1012

13+
# Change directory to TOOLS_DIR
1114
cd "${TOOLS_DIR}" || exit 1
1215

16+
# Function to check the status of the last executed command
1317
function check_status() {
14-
# first param is error message to print in case of error
18+
local error_message="$1"
1519
if [ $? -ne 0 ]; then
16-
if [ -n "$1" ]; then
17-
echo "$1"
20+
if [ -n "$error_message" ]; then
21+
echo "[ERROR]: $error_message"
1822
fi
19-
20-
# Exit 255 to pass signal to xargs to abort process with code 1, in other cases xargs will complete with 0.
23+
# Exit with code 255 to signal xargs to abort the process, otherwise it will return 0
2124
exit 255
2225
fi
2326
}
2427

28+
# Function to install a dependency
2529
function install_dep() {
26-
dep=$1
30+
local dep=$1
2731

28-
bin_out=$GOBIN/$(echo $dep | awk 'BEGIN { FS="/" } {for (i=NF; i>0; i--) if ($i !~ /^v[0-9]/) {print $i;exit}}')
32+
# Extract the binary output path
33+
bin_out="$GOBIN/$(echo "$dep" | awk 'BEGIN { FS="/" } { for (i=NF; i>0; i--) if ($i !~ /^v[0-9]/) { print $i; exit } }')"
2934

30-
echo "[INFO]: Going to build ${dep} - ${bin_out}"
35+
# Determine tools module
36+
tools_module="$(grep '^module ' go.mod | awk '{print $2}')"
3137

32-
go build -mod=vendor -o "${bin_out}" "${dep}"
38+
# Extract the version of the dependency
39+
raw_version=$(go list -mod=readonly -m -f '{{if not .Indirect}}{{.Path}} {{.Version}}{{end}}' all | grep -v "^${tools_module}")
40+
version=$(echo "$raw_version" | awk '{print $2}')
3341

34-
check_status "[FAIL]: build [${dep}] failed!"
42+
echo "[INFO]: Building ${dep}@${version} - Output: ${bin_out}"
43+
44+
# Build the dependency
45+
go build -mod=vendor -o "${bin_out}" "${dep}"
46+
check_status "Build failed for dependency [${dep}@${version}]!"
3547

36-
echo "[SUCCESS]: build [${dep}] finished."
48+
echo "[SUCCESS]: Successfully built [${dep}@${version}]."
3749
}
3850

51+
# Export functions for use in subshells (xargs)
3952
export -f install_dep
4053
export -f check_status
4154

55+
# Function to install dependencies listed in the go.mod file
4256
function install_deps() {
57+
local tools_module
58+
59+
# Extract the tools module name
4360
tools_module="$(grep '^module ' go.mod | awk '{print $2}')"
61+
echo "[INFO]: Installing dependencies for module: ${tools_module}"
4462

45-
echo "[INFO]: Running install_deps for ${tools_module}"
46-
63+
# List and install dependencies using xargs for parallel execution
4764
go list -e -f '{{ join .Imports "\n" }}' -tags="tools" "${tools_module}" |
48-
xargs -n 1 -P 0 -I {} bash -c 'install_dep "$@"' _ {}
65+
xargs -n 1 -P 0 -I {} bash -c 'install_dep "$@"' _ {}
4966
}
5067

68+
# Function to iterate over tools and install them
5169
function install_tools() {
52-
declare -a tools_list
53-
54-
temp_file=./tools_list.txt # создаем временный файл
70+
declare -a tools_list
71+
local temp_file=./tools_list.txt
5572

56-
touch "$temp_file" # создаем временный файл
57-
58-
ls -d ${TOOLS_DIR}/*/ > "$temp_file" # сохраняем вывод команды в файл
73+
# Create a temporary file to store tool directories
74+
touch "$temp_file"
75+
ls -d "${TOOLS_DIR}"/*/ > "$temp_file"
5976

77+
# Read all tool directories into an array
6078
while IFS= read -r t; do
6179
tools_list+=("$t")
62-
done < "$temp_file" # читаем файл в массив
80+
done < "$temp_file"
6381

64-
rm "$temp_file" # удаляем временный файл
82+
# Clean up the temporary file
83+
rm "$temp_file"
6584

85+
# Loop through each tool and install its dependencies
6686
for t in "${tools_list[@]}"; do
67-
echo "In loop - current ${t}"
87+
echo "[INFO]: Processing tool: ${t}"
6888

6989
tool=$(basename "${t}")
7090
cd "${TOOLS_DIR}/${tool}" || exit 1
7191
install_deps
72-
cd - || exit 1
92+
cd - > /dev/null || exit 1
7393
done
7494
}
7595

76-
77-
install_tools
96+
# Start the tool installation process
97+
install_tools

scripts/sync-vendor.sh

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,66 @@
22

33
set -eu
44

5+
# Constants
56
SCRIPT_NAME="$(basename "$0")"
67
SCRIPT_DIR="$(dirname "$0")"
78
REPO_ROOT="$(cd "${SCRIPT_DIR}" && git rev-parse --show-toplevel)"
89
TOOLS_DIR="${REPO_ROOT}/tools"
910

10-
echo "${SCRIPT_NAME} is running... "
11+
echo "${SCRIPT_NAME} is running..."
1112

12-
function sync_vendor() {
13+
# Function to sync the vendor directory
14+
sync_vendor() {
1315
echo "Syncing vendor..."
14-
rm -rf vendor
16+
rm -rf ./vendor
1517
go mod tidy
1618
go mod vendor
1719
}
1820

19-
function check_status() {
20-
# first param is error message to print in case of error
21-
if [ $? -ne 0 ]; then
22-
if [ -n "$1" ]; then
23-
echo "$1"
24-
fi
2521

26-
# Exit 255 to pass signal to xargs to abort process with code 1, in other cases xargs will complete with 0.
27-
exit 255
28-
fi
29-
}
30-
31-
function sync_dep() {
32-
dep=$1
33-
34-
echo "[INFO]: Going to sync ${dep}"
35-
36-
sync_vendor
37-
38-
check_status "[FAIL]: sync [${dep}] failed!"
39-
40-
echo "[SUCCESS]: sync [${dep}] finished."
41-
}
42-
43-
export -f sync_dep
44-
export -f check_status
45-
export -f sync_vendor
46-
47-
function sync_deps() {
22+
# Function to sync dependencies
23+
sync_deps() {
24+
local tools_module
4825
tools_module="$(grep '^module ' go.mod | awk '{print $2}')"
4926

5027
echo "[INFO]: Running install_deps for ${tools_module}"
5128

52-
go list -e -f '{{ join .Imports "\n" }}' -tags="tools" "${tools_module}" |
53-
xargs -n 1 -P 0 -I {} bash -c 'sync_dep "$@"' _ {}
29+
sync_vendor
5430
}
5531

56-
function sync_tools() {
57-
declare -a tools_list
32+
# Function to sync all tools in the TOOLS_DIR
33+
sync_tools() {
34+
local tools_list=()
5835

59-
temp_file=./tools_list.txt # создаем временный файл
36+
# Temporary file to store the list of tools
37+
local temp_file="./tools_list.txt"
38+
touch "${temp_file}"
6039

61-
touch "$temp_file" # создаем временный файл
40+
# Save tools directories into the temporary file
41+
ls -d "${TOOLS_DIR}"/*/ > "${temp_file}"
6242

63-
ls -d ${TOOLS_DIR}/*/ > "$temp_file" # сохраняем вывод команды в файл
43+
# Read tools into an array
44+
while IFS= read -r tool_dir; do
45+
tools_list+=("${tool_dir}")
46+
done < "${temp_file}"
6447

65-
while IFS= read -r t; do
66-
tools_list+=("$t")
67-
done < "$temp_file" # читаем файл в массив
48+
# Remove the temporary file
49+
rm "${temp_file}"
6850

69-
rm "$temp_file" # удаляем временный файл
51+
# Loop through each tool directory and sync dependencies
52+
for tool_path in "${tools_list[@]}"; do
53+
echo "[INFO]: Processing tool directory: ${tool_path}"
7054

71-
for t in "${tools_list[@]}"; do
72-
echo "In loop - current ${t}"
55+
local tool
56+
tool=$(basename "${tool_path}")
7357

74-
tool=$(basename "${t}")
7558
cd "${TOOLS_DIR}/${tool}" || exit 1
7659
sync_deps
77-
cd - || exit 1
60+
cd - > /dev/null || exit 1
7861
done
7962
}
8063

64+
# Start the tool synchronization process
8165
sync_tools
8266

83-
echo "${SCRIPT_NAME} done."
67+
echo "${SCRIPT_NAME} finished."

tools/buf/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module buf
22

3-
go 1.23.4
3+
go 1.23
44

55
require github.com/bufbuild/buf v1.48.0
66

tools/coverbadger/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module coverbadger
22

3-
go 1.23.1
3+
go 1.23
44

55
require github.com/obalunenko/coverbadger v1.4.0
66

tools/enumer/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module enumer
22

3-
go 1.23.1
3+
go 1.23
44

55
require github.com/alvaroloes/enumer v1.1.2
66

tools/fiximports/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module fiximports
22

3-
go 1.23.1
3+
go 1.23
44

55
require golang.org/x/tools v0.28.0

tools/go-enum/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module go-enum
22

3-
go 1.23.1
3+
go 1.23
44

55
require github.com/abice/go-enum v0.6.0
66

tools/gocov-html/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module gocov-html
22

3-
go 1.23.1
3+
go 1.23
44

55
require github.com/matm/gocov-html v1.4.0
66

0 commit comments

Comments
 (0)