-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update template to support ghcr, tag builds, updated Dockerfile
- Loading branch information
Showing
6 changed files
with
59 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,67 @@ | ||
# Go parameters | ||
BINARY_NAME=go-project-template | ||
BINARY_UNIX=$(BINARY_NAME)_unix | ||
REPO=docker.pkg.github.com/dathan/go-project-template/go-project-template | ||
REPO=ghcr.io/dathan/go-project-template/go-project-template | ||
|
||
.PHONY: all | ||
all: lint test build | ||
|
||
.PHONY: lint | ||
lint: | ||
golangci-lint run ./... | ||
golangci-lint run ./... | ||
|
||
.PHONY: buildruntest | ||
buildruntest: build build-linux customrun | ||
|
||
.PHONY: customrun | ||
customrun: | ||
./scripts/customrun.sh | ||
|
||
.PHONY: build | ||
build: | ||
go build -o ./bin ./cmd/... | ||
go build -o ./bin ./cmd/... | ||
|
||
.PHONY: test | ||
test: | ||
go test -p 6 -covermode=count -coverprofile=test/coverage.out test/*.go | ||
go test -p 6 -covermode=count -coverprofile=test/coverage.out test/*.go | ||
|
||
.PHONY: clean | ||
clean: | ||
go clean | ||
find . -type d -name '.tmp_*' -prune -exec rm -rvf {} \; | ||
go clean | ||
find . -type d -name '.tmp_*' -prune -exec rm -rvf {} \; | ||
|
||
.PHONY: run | ||
run: | ||
go run ./cmd/$(BINARY_NAME)/*.go | ||
go run ./cmd/$(BINARY_NAME)/*.go | ||
|
||
.PHONY: vendor | ||
vendor: | ||
go mod vendor | ||
go mod vendor | ||
|
||
# Cross compilation | ||
.PHONY: build-linux | ||
build-linux: | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/$(BINARY_UNIX) -v cmd/$(BINARY_NAME)/ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/$(BINARY_UNIX) -v cmd/$(BINARY_NAME)/*.go | ||
|
||
# Build docker containers | ||
.PHONY: docker-build | ||
docker-build: | ||
# docker build \ | ||
# --build-arg GITHUB_SSH_PRIV_KEY="`cat ~/.ssh/id_rsa`" \ | ||
# -t $(or ${dockerImage},$(BINARY_NAME)-release) . | ||
docker build \ | ||
-t $(or ${dockerImage},$(BINARY_NAME)-release) . | ||
# docker build \ | ||
# --build-arg GITHUB_SSH_PRIV_KEY="`cat ~/.ssh/id_rsa`" \ | ||
# -t $(or ${dockerImage},$(BINARY_NAME)-release) . | ||
docker build \ | ||
-t $(or ${dockerImage},$(BINARY_NAME)-release) . | ||
|
||
.PHONY: docker-tag | ||
docker-tag: | ||
docker tag `docker image ls --filter 'reference=$(BINARY_NAME)-release' -q` $(REPO):`git rev-parse HEAD` | ||
docker tag `docker image ls --filter 'reference=$(BINARY_NAME)-release' -q` $(REPO):`git rev-parse HEAD` | ||
|
||
# Push the container | ||
.PHONY: docker-push | ||
docker-push: docker-build docker-tag | ||
docker push $(REPO):`git rev-parse HEAD` | ||
docker push $(REPO):`git rev-parse HEAD` | ||
|
||
|
||
.PHONY: docker-clean | ||
docker-clean: | ||
docker rmi `docker image ls --filter 'reference=$(BINARY_NAME)-*' -q` | ||
docker rmi `docker image ls --filter 'reference=$(BINARY_NAME)-*' -q` |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
echo "Executing a script designed to run from within Docker" | ||
/app/example1 | ||
/app/example2 | ||
/app/go-project-template |