fix build and docker-compose

This commit is contained in:
rmanach 2025-11-24 15:58:29 +01:00
parent 4af6fc14c5
commit cd2631787a
6 changed files with 129 additions and 110 deletions

12
.dockerignore Normal file
View File

@ -0,0 +1,12 @@
store
builds
.env
.env.example
Makefile
README.md
docker-*.yml
Dockerfile
.dockerignore

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
builds builds
store store
.env .env
*.tar

View File

@ -1,133 +1,100 @@
linters-settings: version: "2"
# depguard: // Specific for golangci repository
# list-type: blacklist
# packages:
# # logging is allowed only by logutils.Log, logrus
# # is allowed to use only in logutils package
# - github.com/sirupsen/logrus
# packages-with-error-message:
# - github.com/sirupsen/logrus: 'logging is allowed only by logutils.Log'
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
sections:
prefix(fetchsysd)
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
# - whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
goimports:
local-prefixes: localenv
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
govet:
shadow: true
# settings: // Specific for golangci repository
# printf:
# funcs:
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 200
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
errcheck:
check-blank: true
exclude-functions:
- '(*github.com/gin-gonic/gin.Error).SetType'
- '(*github.com/gin-gonic/gin.Context).Error'
linters: linters:
disable-all: true default: none
enable: enable:
- bodyclose - bodyclose
# - deadcode # deprecated (since v1.49.0) - copyloopvar
# - depguard
- dogsled - dogsled
- dupl - dupl
- errcheck - errcheck
- copyloopvar
- exhaustive - exhaustive
- funlen - funlen
- gochecknoinits - gochecknoinits
- goconst - goconst
- gocritic - gocritic
- gocyclo - gocyclo
- gofmt
- goimports
- mnd
- goprintffuncname - goprintffuncname
- gosec - gosec
- gosimple
- govet - govet
- ineffassign - ineffassign
- lll - lll
- misspell - misspell
- mnd
- nakedret - nakedret
- noctx - noctx
- nolintlint - nolintlint
# - rowserrcheck # https://github.com/golangci/golangci-lint/issues/2649
- staticcheck - staticcheck
# - structcheck # https://github.com/golangci/golangci-lint/issues/2649
- stylecheck
- typecheck
- unconvert - unconvert
- unparam - unparam
- unused - unused
# - varcheck # deprecated (since v1.49.0)
- whitespace - whitespace
# - gochecknoglobals # too many global in ds9 settings:
dupl:
# don't enable: threshold: 100
# - asciicheck errcheck:
# - scopelint check-blank: true
# - gocognit exclude-functions:
# - godot - (*github.com/gin-gonic/gin.Error).SetType
# - godox - (*github.com/gin-gonic/gin.Context).Error
# - goerr113 funlen:
# - interfacer lines: 100
# - maligned statements: 50
# - nestif goconst:
# - prealloc min-len: 2
# - testpackage min-occurrences: 2
# - revive gocritic:
# - wsl disabled-checks:
- dupImport
# issues: - ifElseChain
# Excluding configuration per-path, per-linter, per-text and per-source - octalLiteral
# fix: true - wrapperFunc
enabled-tags:
run: - diagnostic
timeout: 5m - experimental
skip-dirs: [] - opinionated
- performance
- style
gocyclo:
min-complexity: 15
lll:
line-length: 200
misspell:
locale: US
mnd:
checks:
- argument
- case
- condition
- return
nolintlint:
require-explanation: false
require-specific: false
allow-unused: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
gci:
sections:
- prefix(fetchsysd)
goimports:
local-prefixes:
- localenv
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

22
Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM golang:1.22 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN GOOS=linux go build -o librapi main.go
FROM debian:bookworm-slim
WORKDIR /app
COPY --from=builder /app/librapi .
RUN chmod +x /app/librapi
RUN mkdir -p /app/store
CMD ["./librapi"]

View File

@ -8,5 +8,5 @@ build: lint
lint: lint:
golangci-lint run --fix golangci-lint run --fix
run: lint run: lint build
go run main.go docker compose up

16
docker-compose.yml Normal file
View File

@ -0,0 +1,16 @@
services:
librapi:
image: librapi:local
container_name: librapi
env_file:
- .env
ports:
- "8080:8080"
networks:
- librapi_network
volumes:
- ./store:/app/store:rw
networks:
librapi_network:
driver: bridge