|
set shell := ["bash", "-c"] |
|
container := "rust-dev" |
|
notfound_regex := "[^n][^o][^t] [^f][^o][^u][^n][^d]" # I don't like this but "just" doesn't support negative look ahead |
|
|
|
container_runtime := if `type podman` =~ notfound_regex { |
|
"podman" |
|
} else if `type docker` =~ notfound_regex { |
|
"docker" |
|
} else { |
|
error("podman nor docker executables found") |
|
} |
|
|
|
container_exec := container_runtime + " exec -it " + container |
|
|
|
# helper for starting container runtime |
|
start_container_runtime: |
|
#!/usr/bin/env bash |
|
if [ "{{ container_runtime }}" == "podman" ]; then |
|
podman machine init |
|
podman machine start |
|
else |
|
echo "start docker however it's started" |
|
exit 1 |
|
fi |
|
|
|
|
|
[private] |
|
docker_check: |
|
#!/usr/bin/env bash |
|
if ! {{ container_runtime }} info > /dev/null 2>&1; then |
|
echo "This script uses docker or podman, and neither of them running - please start one of them and try again!" |
|
exit 1 |
|
fi |
|
|
|
[private] |
|
image : docker_check |
|
#!/usr/bin/env bash |
|
if ! {{ container_runtime }} image inspect {{ container }}:dev > /dev/null 2>&1; then |
|
$DOCKER_BUILDKIT=1 {{ container_runtime }} build -t "{{ container }}:dev" \ |
|
--target dev \ |
|
--build-arg HTTP_PROXY=$HTTP_PROXY \ |
|
--build-arg HTTPS_PROXY=$HTTPS_PROXY \ |
|
--build-arg NO_PROXY=$NO_PROXY \ |
|
. |
|
fi |
|
|
|
# force a rebuild of the image |
|
make_image: docker_check |
|
$DOCKER_BUILDKIT=1 {{ container_runtime }} build -t "{{ container }}:dev" \ |
|
--no-cache \ |
|
--target dev \ |
|
--build-arg HTTP_PROXY=$HTTP_PROXY \ |
|
--build-arg HTTPS_PROXY=$HTTPS_PROXY \ |
|
--build-arg NO_PROXY=$NO_PROXY \ |
|
. |
|
|
|
# bring up dev environment container |
|
container: image |
|
#!/usr/bin/env bash |
|
if [ ! "$( {{ container_runtime }} container inspect -f '{{{{.State.Status}}' {{ container }} )" == "running" ]; then |
|
CONTAINER_NAME="{{ container }}" docker-compose up -d |
|
fi |
|
|
|
|
|
# build debug binary |
|
build: container |
|
{{ container_exec }} cargo build |
|
|
|
# run all tests |
|
test-all: container |
|
{{ container_exec }} cargo test |
|
|
|
# run a specific test |
|
test TEST: container |
|
{{ container_exec }} cargo test {{ TEST }} |
|
|
|
# build release binary |
|
release: container |
|
{{ container_exec }} cargo build --release |
|
|
|
# execute a command within the conainter |
|
run *COMMAND: container |
|
{{ container_exec }} {{ COMMAND }} |
|
|
|
# bring down dev environment container |
|
stop_container: container |
|
docker-compose stop && docker-compose down |