forked from rofrano/vagrant-docker-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (42 loc) · 1.55 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## ----------------------------------------------------------------------
## Builder for creating Docker images that behave similar to Virtual
## Machines for use with Vagrant. This takes advantage if the buildx
## builder in docker which can cross-compile images for other targets.
## ----------------------------------------------------------------------
# These can be overidden with env vars.
REGISTRY ?= rofrano
IMAGE_NAME ?= vagrant-provider
IMAGE_TAG ?= ubuntu
IMAGE ?= $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
PLATFORM ?= "linux/amd64,linux/arm64"
# Set up the Docker build environment
.EXPORT_ALL_VARIABLES:
DOCKER_BUILDKIT = 1
all: build
## help: Lists help on the commands
.PHONY: help
help: Makefile
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
.PHONY: clean
clean: ## Removes all dangling build cache
$(info Removing all dangling build cache)
echo Y | docker buildx prune
.PHONY: init
init: export DOCKER_BUILDKIT=1
init: ## Creates the buildx instance
$(info Initializing Builder...)
docker buildx create --use --name=qemu
docker buildx inspect --bootstrap
.PHONY: build
build: ## Build all of the project Docker images
$(info Building $(IMAGE) for $(PLATFORM)...)
docker buildx build --file Dockerfile.$(IMAGE_TAG) --pull --platform=$(PLATFORM) --tag $(IMAGE) --push .
.PHONY: run
run: ## Run a vagrant VM using this image
$(info Bringing up virtual machine with Docker...)
vagrant up --provider=docker
.PHONY: remove
remove: ## Stop and remove the buildx builder
$(info Stopping and removing the builder image...)
docker buildx stop
docker buildx rm