-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Still suffering from vasi/qcow2-fuse#4
- Loading branch information
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ARG ALPINE_VERSION | ||
FROM docker.io/library/alpine:$ALPINE_VERSION | ||
# https://github.com/vasi/qcow2-fuse/issues/4 | ||
RUN set -ex \ | ||
&& apk add libgcc fuse qemu-img \ | ||
&& apk add --virtual .build-deps \ | ||
curl \ | ||
rust \ | ||
cargo \ | ||
fuse-dev \ | ||
pkgconf \ | ||
&& cargo install --root /usr/local qcow2-fuse \ | ||
&& apk del .build-deps \ | ||
&& rm -rf /tmp/* /var/cache/apk/* /root/.cargo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ QEMU_IMG = qemu-img | |
JQ = jq | ||
SSH = ssh | ||
|
||
alpine.branch = v3.15 | ||
alpine.version = 3.15 | ||
alpine.qcow2.size = 8G | ||
alpine.qcow2.opts = -o nocow=on | ||
alpine-make-vm-image.url = https://raw.githubusercontent.com/alpinelinux/alpine-make-vm-image/v0.8.0/alpine-make-vm-image | ||
|
@@ -27,14 +27,40 @@ destroy: | |
$(TF) destroy -auto-approve | ||
-rm terraform.tfstate terraform.tfstate.backup | ||
|
||
.docker-image.%: Dockerfile.% | ||
docker build --iidfile '[email protected]' --build-arg ALPINE_VERSION='$(alpine.version)' - <'$^' | ||
mv -- '[email protected]' '$@' | ||
|
||
.PHONY: docker-test | ||
docker-test: .docker-image.build | ||
docker-test: QEMU_IMG = docker run --rm \ | ||
--volume '$(CURDIR):/build' --workdir /build \ | ||
--user $(shell id -u):$(shell id -g) \ | ||
--entrypoint qemu-img \ | ||
'$(shell cat .docker-image.build)' | ||
docker-test: SUDO = docker run --rm \ | ||
--volume '$(CURDIR):/build' --workdir /build \ | ||
'$(shell cat .docker-image.build)' | ||
docker-test: alpine.qcow2 | ||
|
||
# $(eval image_format = $(patsubst .%,%,$(suffix $@))) | ||
# @echo Building $@ ... | ||
# $(MAKE) alpine.qcow2 QEMU_IMG='docker run --rm $(shell cat .docker-image.build) --user $(shell id -u):$(shell id -g)' | ||
|
||
# @[ ! -f '$@' ] || rm -f -- '$@' | ||
# docker run --rm docker.io/library/alpine:'$(alpine.branch)' \ | ||
# --user '$(shell id -u):$(shell id -g)' \ | ||
# sh -c | ||
# -rm terraform.tfstate terraform.tfstate.backup | ||
|
||
alpine.qcow2: image/alpine-make-vm-image image/packages image/build.sh | ||
$(eval image_format = $(patsubst .%,%,$(suffix $@))) | ||
@echo Building $@ ... | ||
@[ ! -f '$@' ] || rm -f -- '$@' | ||
@{ \ | ||
$(QEMU_IMG) create -f '$(image_format)' $($@.opts) '[email protected]' '$([email protected])' \ | ||
&& $(SUDO) image/alpine-make-vm-image \ | ||
--branch '$(alpine.branch)' \ | ||
--branch 'v$(alpine.version)' \ | ||
--image-format '$(image_format)' \ | ||
--packages '$(shell cat image/packages)' \ | ||
--script-chroot \ | ||
|
@@ -70,6 +96,8 @@ clean: | |
-rm -f image/alpine-make-vm-image alpine.qcow2 alpine.qcow2.tmp | ||
-rm -rf .terraform | ||
-rm id_rsa id_rsa.pub | ||
-docker rmi "$(shell cat .docker-image.*)" | ||
-rm .docker-image.* | ||
|
||
.terraform.lock.hcl: main.tf | ||
$(TF) init |