diff --git a/Dockerfile b/Dockerfile index 8b1f413..55e3326 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -# Первый этап: сборка приложения FROM golang:latest AS builder WORKDIR /app @@ -6,9 +5,8 @@ WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN go build -o aides-repo-api ./cmd/aides-repo-api/main.go +RUN make build -# Второй этап: создание финального образа FROM registry.altlinux.org/sisyphus/alt:20241211 RUN \ diff --git a/Makefile b/Makefile index 62d717a..e868ea3 100644 --- a/Makefile +++ b/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 SWAG := go run github.com/swaggo/swag/cmd/swag@v1.16.4 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" $(GOLANGCI_LINT) run --fix $(SWAG) fmt @@ -10,4 +17,13 @@ format: swag: $(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 diff --git a/docs/docs.go b/docs/docs.go index 5f791b5..843fefa 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -71,7 +71,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "tasks" + "Tasks" ], "summary": "Upload files to a task", "parameters": [ diff --git a/docs/swagger.json b/docs/swagger.json index cf4f64e..7804bcf 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -60,7 +60,7 @@ "application/json" ], "tags": [ - "tasks" + "Tasks" ], "summary": "Upload files to a task", "parameters": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 77c98c2..41f36c8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -117,5 +117,5 @@ paths: $ref: '#/definitions/errors.ErrResponse' summary: Upload files to a task tags: - - tasks + - Tasks swagger: "2.0" diff --git a/internal/config/version.go b/internal/config/version.go new file mode 100644 index 0000000..6f29241 --- /dev/null +++ b/internal/config/version.go @@ -0,0 +1,3 @@ +package config + +var Version = "unknown" diff --git a/internal/router/router.go b/internal/router/router.go index 942b2e1..81f8567 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -4,7 +4,7 @@ import ( "github.com/go-chi/chi/v5" 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/controllers/taskcontroller" "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.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.Route("/tasks", func(taskRouter chi.Router) {