Compare commits
1 Commits
5d3e0667de
...
fix/module
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14525523cb |
39
Dockerfile
39
Dockerfile
@@ -1,32 +1,35 @@
|
|||||||
# Lint stage — fast feedback on formatting and lint issues
|
# Build stage
|
||||||
# golangci/golangci-lint:v2.10.1
|
|
||||||
FROM golangci/golangci-lint@sha256:ea84d14c2fef724411be7dc45e09e6ef721d748315252b02df19a7e3113ee763 AS lint
|
|
||||||
|
|
||||||
WORKDIR /src
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN make fmt-check
|
|
||||||
RUN make lint
|
|
||||||
|
|
||||||
# Build stage — tests and compilation
|
|
||||||
# golang:1.25-alpine
|
# golang:1.25-alpine
|
||||||
FROM golang@sha256:f6751d823c26342f9506c03797d2527668d095b0a15f1862cddb4d927a7a4ced AS builder
|
FROM golang@sha256:f6751d823c26342f9506c03797d2527668d095b0a15f1862cddb4d927a7a4ced AS builder
|
||||||
|
|
||||||
# Force BuildKit to run the lint stage by creating a stage dependency
|
|
||||||
COPY --from=lint /src/go.sum /dev/null
|
|
||||||
|
|
||||||
RUN apk add --no-cache git make gcc musl-dev
|
RUN apk add --no-cache git make gcc musl-dev
|
||||||
|
|
||||||
|
# Install golangci-lint v2 (pre-built binary — go install fails in alpine due to missing linker)
|
||||||
|
RUN set -e; \
|
||||||
|
GOLANGCI_VERSION="2.10.1"; \
|
||||||
|
case "$(uname -m)" in \
|
||||||
|
x86_64) ARCH="amd64"; SHA256="dfa775874cf0561b404a02a8f4481fc69b28091da95aa697259820d429b09c99" ;; \
|
||||||
|
aarch64) ARCH="arm64"; SHA256="6652b42ae02915eb2f9cb2a2e0cac99514c8eded8388d88ae3e06e1a52c00de8" ;; \
|
||||||
|
*) echo "unsupported arch: $(uname -m)" >&2; exit 1 ;; \
|
||||||
|
esac; \
|
||||||
|
wget -q -O /tmp/golangci-lint.tar.gz \
|
||||||
|
"https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_VERSION}/golangci-lint-${GOLANGCI_VERSION}-linux-${ARCH}.tar.gz"; \
|
||||||
|
echo "${SHA256} /tmp/golangci-lint.tar.gz" | sha256sum -c -; \
|
||||||
|
tar -xzf /tmp/golangci-lint.tar.gz -C /usr/local/bin --strip-components=1 "golangci-lint-${GOLANGCI_VERSION}-linux-${ARCH}/golangci-lint"; \
|
||||||
|
rm /tmp/golangci-lint.tar.gz; \
|
||||||
|
golangci-lint version
|
||||||
|
RUN go install golang.org/x/tools/cmd/goimports@009367f5c17a8d4c45a961a3a509277190a9a6f0 # v0.42.0
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN make test
|
# Run all checks - build fails if any check fails
|
||||||
|
RUN make check
|
||||||
|
|
||||||
|
# Build the binary
|
||||||
RUN make build
|
RUN make build
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
|
|||||||
15
Makefile
15
Makefile
@@ -1,4 +1,4 @@
|
|||||||
.PHONY: all build lint fmt fmt-check test check clean
|
.PHONY: all build lint fmt test check clean
|
||||||
|
|
||||||
BINARY := upaasd
|
BINARY := upaasd
|
||||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||||
@@ -18,15 +18,20 @@ fmt:
|
|||||||
goimports -w .
|
goimports -w .
|
||||||
npx prettier --write --tab-width 4 static/js/*.js
|
npx prettier --write --tab-width 4 static/js/*.js
|
||||||
|
|
||||||
fmt-check:
|
|
||||||
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -v -race -cover ./...
|
go test -v -race -cover ./...
|
||||||
|
|
||||||
# Check runs all validation without making changes
|
# Check runs all validation without making changes
|
||||||
# Used by CI and Docker build - fails if anything is wrong
|
# Used by CI and Docker build - fails if anything is wrong
|
||||||
check: fmt-check lint test
|
check:
|
||||||
|
@echo "==> Checking formatting..."
|
||||||
|
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
||||||
|
@echo "==> Running linter..."
|
||||||
|
golangci-lint run --config .golangci.yml ./...
|
||||||
|
@echo "==> Running tests..."
|
||||||
|
go test -v -race ./...
|
||||||
|
@echo "==> Building..."
|
||||||
|
go build -ldflags "$(LDFLAGS)" -o /dev/null ./cmd/upaasd
|
||||||
@echo "==> All checks passed!"
|
@echo "==> All checks passed!"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
Reference in New Issue
Block a user