Skip to content

Commit

Permalink
Improved the local build process.
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann Mayer <[email protected]>
  • Loading branch information
Jack12816 committed Oct 21, 2024
1 parent af5211a commit 827517c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ SLEEP ?= sleep
GREP ?= grep
EXIT ?= exit

CONTAINER_REGISTRY ?=
CONTAINER_NAME ?= hausgold/mdns-proxy
CONTAINER_URI ?= $(CONTAINER_REGISTRY)$(CONTAINER_NAME)
CONTAINER_URI_DEV ?= $(CONTAINER_URI):dev
CONTAINER_URI_LATEST ?= $(CONTAINER_URI):latest
IMAGE_REGISTRY ?=
IMAGE_NAME ?= hausgold/mdns-proxy
IMAGE_URI ?= $(IMAGE_REGISTRY)$(IMAGE_NAME):latest

ON_ERROR := $(DOCKER) ps; $(DOCKER) logs mdns-test; $(EXIT) 1;

Expand Down Expand Up @@ -62,7 +60,7 @@ all:

build: clean
# Build the Docker image
@$(TIME) $(DOCKER) build --no-cache -t "$(CONTAINER_URI_DEV)" .
@$(TIME) $(DOCKER) build --no-cache -t "$(IMAGE_URI)" .

test:
# Test the built Docker image
Expand All @@ -71,7 +69,7 @@ test:
@$(DOCKER) rm -fv mdns-test || true
#
# Start the built image
@$(DOCKER) run --name mdns-test -p 80:80 -d "$(CONTAINER_URI_DEV)"
@$(DOCKER) run --name mdns-test -p 80:80 -d "$(IMAGE_URI)"
#
# Sleep a bit until the service is booted
@$(call check-service,localhost:80,$(ON_ERROR))
Expand All @@ -82,13 +80,12 @@ test:

publish:
# Push the new Docker image to the registry
@$(DOCKER) tag "$(CONTAINER_URI_DEV)" "$(CONTAINER_URI_LATEST)"
@$(call retry,$(TIME) $(SHELL) -c '$(DOCKER) push $(CONTAINER_URI_LATEST)')
@$(call retry,$(TIME) $(SHELL) -c '$(DOCKER) push $(IMAGE_URI)')

shell:
# Start an individual test session of the image
@$(DOCKER) run --rm -it "$(CONTAINER_URI_DEV)" bash
@$(DOCKER) run --rm -it "$(IMAGE_URI)" bash

clean:
# Clean the current development snapshot
@$(DOCKER) rmi --force "$(CONTAINER_URI_DEV)" || true
@$(DOCKER) rmi --force "$(IMAGE_URI)" || true

0 comments on commit 827517c

Please sign in to comment.