Add common tools
This commit is contained in:
parent
930eaaebfb
commit
7200d400f0
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.idea
|
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM debian:11.6-slim
|
||||
|
||||
COPY . /src
|
||||
RUN for file in $(find /src -type f -name "*.sh"); do chmod +x $file; done
|
||||
|
||||
RUN /src/scripts/workers/debian.sh
|
||||
RUN /src/scripts/workers/golang.sh
|
||||
RUN /src/scripts/workers/golangci-lint.sh
|
||||
RUN /src/scripts/workers/gofumpt.sh
|
||||
RUN /src/scripts/workers/taskfile.sh
|
||||
|
||||
RUN mkdir /home/container && chmod 0777 /home/container
|
||||
|
||||
ENV HOME=/home/container
|
||||
ENV GOPATH=/home/container/go
|
||||
ENV GOCACHE=/home/container/.cache
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
Copyright (c) 2023 Vladimir Khodakov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
11
README.md
11
README.md
@ -1,3 +1,14 @@
|
||||
# toolbox
|
||||
|
||||
Докер-тулбокс с гошными и окологошными тулзами, которые я использую для разработки.
|
||||
|
||||
## Что присутствует
|
||||
|
||||
В качестве базового образа используется Debian 11 (slim).
|
||||
|
||||
| Бинарный файл | Версия | Проект | Репозиторий |
|
||||
| ----------------- |-------------| --------------- | ------------------------------------------------------------- |
|
||||
| `go` | 1.20.3 | Go | |
|
||||
| `golangci-lint` | 1.52.2 | golangci-lint | [Внешняя ссылка](https://github.com/golangci/golangci-lint) |
|
||||
| `gofumpt` | 0.5.0 | gofumpt | [Внешняя ссылка](https://github.com/mvdan/gofumpt) |
|
||||
| `task` | 3.24.0 | taskfile | [Внешняя ссылка](https://github.com/go-task/task) |
|
||||
|
19
build.sh
Normal file
19
build.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# build.sh checks if docker image with same sha256 exists remotely.
|
||||
# if exists, do nothing, if not, build the image
|
||||
|
||||
commit_sha="${CI_COMMIT_SHA}"
|
||||
registry_uri="${CI_PROJECT_URL}"
|
||||
image_name="${CI_REGISTRY_IMAGE}"
|
||||
arch="${ARCH}"
|
||||
|
||||
echo "* Building docker image ${image_name}:${commit_sha}-${arch}..."
|
||||
|
||||
if docker manifest inspect "${image_name}:${commit_sha}-${arch}" >/dev/null; then
|
||||
echo "* Docker image ${image_name}:${commit_sha}-${arch} is already exists on remote, no rebuilt necessary."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
docker build --pull --build-arg VCS_REF=${commit_sha} --build-arg VCS_URL=${registry_uri} --tag ${image_name}:${commit_sha}-${arch} .
|
||||
docker push ${image_name}:${commit_sha}-${arch}
|
17
scripts/helpers/arch.sh
Normal file
17
scripts/helpers/arch.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
# Line above disables shellcheck linters:
|
||||
# * SC2043 - unused variable (this file sourced elsewhere).
|
||||
|
||||
base_arch=$(uname -m)
|
||||
arch=""
|
||||
|
||||
if [ "$base_arch" = "x86_64" ]; then
|
||||
arch=amd64
|
||||
elif [ "$base_arch" = "aarch64" ]; then
|
||||
arch=arm64
|
||||
else
|
||||
echo "unknown arch"
|
||||
exit 1
|
||||
fi
|
4
scripts/workers/debian.sh
Normal file
4
scripts/workers/debian.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
apt update && apt upgrade -y
|
||||
apt install -y build-essential curl file git make
|
12
scripts/workers/gofumpt.sh
Normal file
12
scripts/workers/gofumpt.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
gofumpt_version="0.5.0"
|
||||
|
||||
set -xe
|
||||
|
||||
cd /tmp
|
||||
git clone https://github.com/mvdan/gofumpt.git
|
||||
cd gofumpt || exit 1
|
||||
git checkout "v${gofumpt_version}"
|
||||
go build -o /usr/local/bin/gofumpt .
|
||||
rm -rf /tmp/gofumpt
|
22
scripts/workers/golang.sh
Normal file
22
scripts/workers/golang.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
# Line above disables shellcheck linters:
|
||||
# * SC2154 - variable referenced but not assigned (false positive, assigned when sourced arch.sh).
|
||||
|
||||
set -xe
|
||||
|
||||
go_version=1.20.3
|
||||
|
||||
# shellcheck disable=SC2086,SC2046,SC2164
|
||||
cd $(dirname ${BASH_SOURCE[0]})
|
||||
script_path=$(pwd)
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source "${script_path}/../helpers/arch.sh"
|
||||
|
||||
curl "https://dl.google.com/go/go${go_version}.linux-${arch}.tar.gz" -o "/tmp/go-${arch}.tar.gz"
|
||||
file "/tmp/go-${arch}.tar.gz"
|
||||
tar -xf "/tmp/go-${arch}.tar.gz" -C /usr/local/
|
||||
rm "/tmp/go-${arch}.tar.gz"
|
||||
ln -s /usr/local/go/bin/* /usr/local/bin
|
20
scripts/workers/golangci-lint.sh
Normal file
20
scripts/workers/golangci-lint.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
# Line above disables shellcheck linters:
|
||||
# * SC2154 - variable referenced but not assigned (false positive, assigned when sourced arch.sh).
|
||||
|
||||
golangci_lint_version=1.52.2
|
||||
|
||||
# shellcheck disable=SC2086,SC2046,SC2164
|
||||
cd "$(dirname ${BASH_SOURCE[0]})"
|
||||
script_path=$(pwd)
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source "${script_path}/../helpers/arch.sh"
|
||||
|
||||
curl -L "https://github.com/golangci/golangci-lint/releases/download/v${golangci_lint_version}/golangci-lint-${golangci_lint_version}-linux-${arch}.tar.gz" -o "/tmp/golangci-lint-${arch}.tar.gz"
|
||||
file "/tmp/golangci-lint-${arch}.tar.gz"
|
||||
tar -xf "/tmp/golangci-lint-${arch}.tar.gz" -C /tmp
|
||||
mv "/tmp/golangci-lint-${golangci_lint_version}-linux-${arch}/golangci-lint" /usr/local/bin
|
||||
rm -rf "/tmp/golangci-lint-${arch}.tar.gz" "/tmp/golangci-lint-${golangci_lint_version}-linux-${arch}/"
|
21
scripts/workers/taskfile.sh
Normal file
21
scripts/workers/taskfile.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
# Line above disables shellcheck linters:
|
||||
# * SC2154 - variable referenced but not assigned (false positive, assigned when sourced arch.sh).
|
||||
|
||||
taskfile_version=3.24.0
|
||||
|
||||
# shellcheck disable=SC2086,SC2046,SC2164
|
||||
cd "$(dirname ${BASH_SOURCE[0]})"
|
||||
script_path=$(pwd)
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source "${script_path}/../helpers/arch.sh"
|
||||
|
||||
curl -L "https://github.com/go-task/task/releases/download/v${taskfile_version}/task_linux_${arch}.tar.gz" -o "/tmp/taskfile-${arch}.tar.gz"
|
||||
file "/tmp/taskfile-${arch}.tar.gz"
|
||||
tar -xf "/tmp/taskfile-${arch}.tar.gz" -C /tmp
|
||||
mv "/tmp/task" /usr/local/bin
|
||||
rm -rf "/tmp/*"
|
||||
ls -la /usr/local/bin
|
Loading…
Reference in New Issue
Block a user