-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(makefile): adding docker-build
and docker-run
targets to the makefile
#71
base: main
Are you sure you want to change the base?
Changes from 2 commits
7cc9174
c4b6e6c
8409a03
f7fa641
ed683ae
d856a5e
c221af6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ SHELL=/bin/bash -e -o pipefail | |
PWD = $(shell pwd) | ||
GO_BUILD= go build | ||
GOFLAGS= CGO_ENABLED=0 | ||
REGISTRY_IMAGE_NAME=golang_app | ||
|
||
## help: Print this help message | ||
.PHONY: help | ||
|
@@ -40,3 +41,17 @@ fmt: | |
.PHONY: build | ||
build: | ||
$(GOFLAGS) $(GO_BUILD) -a -v -ldflags="-w -s" -o bin/app cmd/main.go | ||
|
||
## docker-build: Builds a docker image | ||
.PHONY: docker-build | ||
docker-build: | ||
docker build . -t $(REGISTRY_IMAGE_NAME) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we can run this as |
||
|
||
## docker-run: Runs the docker image built by make docker-build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atallison, Can we keep the help messages consistent? "Build" instead of "Builds" etc. Maybe we should update the message to "Runs the docker image built via [make docker-build]" to separate out that it is a command? |
||
.PHONY: docker-run | ||
docker-run: | ||
docker run $(REGISTRY_IMAGE_NAME) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atallison, We should probably add the |
||
|
||
## docker: Builds and runs the docker image | ||
.PHONY: docker | ||
docker: docker-build docker-run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atallison I would replace the var name with
DOCKER_REPO
for 2 reasons: the prefixDOCKER
signifies the scope and a docker repo is usually synonymous with<registry>/<image>
.I would also replace the value to
rog-golang-buddies/template
.