chore: add config.version, docker image building in make and others
This commit is contained in:
parent
1a7d9ea797
commit
33e51735cf
7 changed files with 28 additions and 7 deletions
|
@ -1,4 +1,3 @@
|
||||||
# Первый этап: сборка приложения
|
|
||||||
FROM golang:latest AS builder
|
FROM golang:latest AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
@ -6,9 +5,8 @@ WORKDIR /app
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go build -o aides-repo-api ./cmd/aides-repo-api/main.go
|
RUN make build
|
||||||
|
|
||||||
# Второй этап: создание финального образа
|
|
||||||
FROM registry.altlinux.org/sisyphus/alt:20241211
|
FROM registry.altlinux.org/sisyphus/alt:20241211
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
|
|
16
Makefile
16
Makefile
|
@ -1,7 +1,14 @@
|
||||||
|
GIT_VERSION = $(shell git describe --tags )
|
||||||
GOLANGCI_LINT := go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
|
GOLANGCI_LINT := go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
|
||||||
SWAG := go run github.com/swaggo/swag/cmd/swag@v1.16.4
|
SWAG := go run github.com/swaggo/swag/cmd/swag@v1.16.4
|
||||||
|
|
||||||
format:
|
format:
|
||||||
|
@echo "🛠️ Format and Lint code with golangci-lint"
|
||||||
|
$(GOLANGCI_LINT) run
|
||||||
|
$(SWAG) fmt
|
||||||
|
@echo "✅ Format and Lint done."
|
||||||
|
|
||||||
|
format-fix:
|
||||||
@echo "🛠️ Format and Lint code with golangci-lint"
|
@echo "🛠️ Format and Lint code with golangci-lint"
|
||||||
$(GOLANGCI_LINT) run --fix
|
$(GOLANGCI_LINT) run --fix
|
||||||
$(SWAG) fmt
|
$(SWAG) fmt
|
||||||
|
@ -10,4 +17,13 @@ format:
|
||||||
swag:
|
swag:
|
||||||
$(SWAG) init -g cmd/aides-repo-api/main.go
|
$(SWAG) init -g cmd/aides-repo-api/main.go
|
||||||
|
|
||||||
|
build:
|
||||||
|
go build \
|
||||||
|
-ldflags="-X 'code.alt-gnome.ru/aides-infra/aides-repo-api/internal/config.Version=$(GIT_VERSION)'" \
|
||||||
|
-o aides-repo-api \
|
||||||
|
./cmd/aides-repo-api/main.go
|
||||||
|
|
||||||
|
build-docker:
|
||||||
|
docker build -t ghcr.io/aides-infra/aides-repo-api .
|
||||||
|
|
||||||
.PHONY: format swag
|
.PHONY: format swag
|
||||||
|
|
|
@ -71,7 +71,7 @@ const docTemplate = `{
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"tasks"
|
"Tasks"
|
||||||
],
|
],
|
||||||
"summary": "Upload files to a task",
|
"summary": "Upload files to a task",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"tasks"
|
"Tasks"
|
||||||
],
|
],
|
||||||
"summary": "Upload files to a task",
|
"summary": "Upload files to a task",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
|
|
@ -117,5 +117,5 @@ paths:
|
||||||
$ref: '#/definitions/errors.ErrResponse'
|
$ref: '#/definitions/errors.ErrResponse'
|
||||||
summary: Upload files to a task
|
summary: Upload files to a task
|
||||||
tags:
|
tags:
|
||||||
- tasks
|
- Tasks
|
||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
|
|
3
internal/config/version.go
Normal file
3
internal/config/version.go
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
var Version = "unknown"
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
httpSwagger "github.com/swaggo/http-swagger"
|
httpSwagger "github.com/swaggo/http-swagger"
|
||||||
|
|
||||||
_ "code.alt-gnome.ru/aides-infra/aides-repo-api/docs"
|
docs "code.alt-gnome.ru/aides-infra/aides-repo-api/docs"
|
||||||
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/config"
|
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/config"
|
||||||
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/controllers/taskcontroller"
|
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/controllers/taskcontroller"
|
||||||
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/logger"
|
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/logger"
|
||||||
|
@ -33,6 +33,10 @@ func (r *Router) Setup() *chi.Mux {
|
||||||
router := chi.NewRouter()
|
router := chi.NewRouter()
|
||||||
router.Use(logger)
|
router.Use(logger)
|
||||||
|
|
||||||
|
docs.SwaggerInfo.Title = "Aides Repo API"
|
||||||
|
docs.SwaggerInfo.Version = config.Version
|
||||||
|
docs.SwaggerInfo.BasePath = "/"
|
||||||
|
docs.SwaggerInfo.Schemes = []string{"https"}
|
||||||
router.Get("/swagger/*", httpSwagger.WrapHandler)
|
router.Get("/swagger/*", httpSwagger.WrapHandler)
|
||||||
|
|
||||||
router.Route("/tasks", func(taskRouter chi.Router) {
|
router.Route("/tasks", func(taskRouter chi.Router) {
|
||||||
|
|
Loading…
Reference in a new issue