Skip to content

feat(makefile): adding docker-build and docker-run targets to the makefile #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ SHELL=/bin/bash -e -o pipefail
PWD = $(shell pwd)
GO_BUILD= go build
GOFLAGS= CGO_ENABLED=0
DOCKER_REPO=rog-golang-buddies/template
DOCKER_TAG=latest

## help: Print this help message
.PHONY: help
Expand Down Expand Up @@ -40,3 +42,17 @@ fmt:
.PHONY: build
build:
$(GOFLAGS) $(GO_BUILD) -a -v -ldflags="-w -s" -o bin/app cmd/main.go

## docker-build: Build docker image
.PHONY: docker-build
docker-build:
docker build . -t $(DOCKER_REPO):$(DOCKER_TAG)

## docker-run: Run docker image built via `make docker-build`
.PHONY: docker-run
docker-run:
docker run --rm $(DOCKER_REPO)

## docker: Build and run docker image
.PHONY: docker
docker: docker-build docker-run