Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

atallison
Copy link

@atallison atallison commented Aug 1, 2022

Description

Adding three new make file targets, make docker-build, make docker-run and make docker for convenience in building and running the docker image of the project.

Fixes #49

Current status

  • Waiting for review
  • Waiting for comment resolution
  • Waiting for merge
  • Draft

Semantic Versioning

  • This is a feat change

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Manual

  1. Navigate to the project directory in the terminal
  2. Enter make docker-build
  3. Verify that a new image is created in docker desktop
  4. Change the REGISTRY_IMAGE_NAME variable in the make file
  5. Re-run make docker-build
  6. Verify that the new image is tagged with the updated variable
  7. Enter make docker-run
  8. Ensure that the image is used in a container that runs
  9. Enter make docker
  10. Ensure that the docker image is made and a container is run with the image

Checklist:

  • My commit message mentions fix, feat, BREAKING CHANGE accordingly to increase the semantic versioning
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have checked my code/docs and corrected any misspellings

Copy link
Collaborator

@haani-niyaz haani-niyaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atallison Thanks for taking this one up! I've left some review comments.

Makefile Outdated
@@ -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
Copy link
Collaborator

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 prefix DOCKER signifies the scope and a docker repo is usually synonymous with <registry>/<image>.

I would also replace the value to rog-golang-buddies/template.

Makefile Outdated
## docker-build: Builds a docker image
.PHONY: docker-build
docker-build:
docker build . -t $(REGISTRY_IMAGE_NAME)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we can run this as make docker REGISTRY_IMAGE_NAME=template override the image, we should also use DOCKER_TAG with a default value of latest. That way the tag can be explicitly set, specially in CI.

Makefile Outdated
## docker-run: Runs the docker image built by make docker-build
.PHONY: docker-run
docker-run:
docker run $(REGISTRY_IMAGE_NAME)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atallison, We should probably add the --rm option to automatically removes the container on exit.

Makefile Outdated
docker-build:
docker build . -t $(REGISTRY_IMAGE_NAME)

## docker-run: Runs the docker image built by make docker-build
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add docker build and run targets to Makefile
3 participants