Skip to content

Commit c43e67c

Browse files
Initial commit
0 parents  commit c43e67c

File tree

1,329 files changed

+396179
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,329 files changed

+396179
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# IDEs
2+
.idea
3+
.vscode
4+
5+
# Keep `swag`
6+
vendor/github.com/swaggo/swag/.gitignore

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM golang:1.14 as gobuild
2+
ARG VERSION=latest
3+
4+
WORKDIR /go/src/github.com/jonnylangefeld/go-api
5+
ADD go.mod go.sum main.go ./
6+
ADD vendor ./vendor
7+
ADD pkg ./pkg
8+
ADD docs ./docs
9+
10+
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -mod=vendor -o go-api -ldflags "-X main.version=$VERSION" main.go
11+
12+
FROM gcr.io/distroless/base
13+
14+
COPY --from=gobuild /go/src/github.com/jonnylangefeld/go-api/go-api /bin
15+
16+
ENTRYPOINT ["/bin/go-api"]

Makefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
VERSION ?= $(shell git describe --match 'v[0-9]*' --tags --always)
2+
3+
build:
4+
@go build -ldflags "-X main.version=$(VERSION)"
5+
6+
version:
7+
@echo $(VERSION)
8+
9+
generate-docs:
10+
@go run ./vendor/github.com/swaggo/swag/cmd/swag/main.go init -g pkg/api/api.go
11+
12+
run:
13+
@docker start go-api-database &> /dev/null || docker run -d \
14+
--name go-api-database \
15+
-e POSTGRES_PASSWORD=secret \
16+
-p 5432:5432 postgres &> /dev/null
17+
@DB_CONNECTION='postgresql://postgres:secret@localhost:5432/postgres?sslmode=disable' \
18+
go run -ldflags "-X main.version=$(VERSION)" main.go
19+
20+
docker:
21+
@docker build -t go-api:$(VERSION) .
22+
23+
test:
24+
@go test -v ./...
25+
26+
generate:
27+
@go generate ./...
28+
29+
tools:
30+
@cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %

0 commit comments

Comments
 (0)