add Dockerfile

This commit is contained in:
Ruidy 2022-06-02 18:19:37 +02:00
parent 0735ea5f00
commit b50b5aea17
3 changed files with 23 additions and 3 deletions

20
Dockerfile Normal file
View file

@ -0,0 +1,20 @@
FROM golang:1.17-alpine AS builder
ENV GOOS linux
RUN apk update --no-cache
WORKDIR /app
COPY go.* .
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o dist
FROM gcr.io/distroless/static
WORKDIR /app
COPY --from=builder /app/dist /app/dist
CMD ["./dist"]

View file

@ -7,7 +7,7 @@ dev:
air
build:
go build -o $(EXECPATH) .
go build -ldflags="-s -w" -o $(EXECPATH) .
run: build
$(EXECPATH) new
@ -19,6 +19,6 @@ web:
cd client && npm run start
test:
go test -json -count=1 ./... -coverpkg=./... -coverprofile coverage.out -covermode=atomic | gotestfmt # && go tool cover -html coverage.out && rm coverage.out
go test -json -count=1 ./... -coverpkg=./... -coverprofile coverage.out -covermode=atomic | gotestfmt && go tool cover -html coverage.out && rm coverage.out
.PHONY: lint run dev run-web test build

2
go.mod
View file

@ -5,12 +5,12 @@ go 1.17
require (
github.com/fatih/color v1.13.0
github.com/go-chi/chi/v5 v5.0.4
github.com/go-chi/cors v1.2.0
github.com/go-chi/render v1.0.1
github.com/spf13/cobra v1.2.1
)
require (
github.com/go-chi/cors v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect