# just image alpine 3.20
# just image alpine 3.21 4.4.3
# just image alpine 3.22 4.5.0
# just image ubuntu jammy 4.4.3
# just image ubuntu noble 4.4.3
# just image redhat 8 4.4.3
# just image redhat 9 4.4.3
# just image redhat 10
image OS OS_VERSION R_VERSION :
    if echo "{{OS}}" | grep -qi "redhat"; then \
        docker buildx build --progress plain --build-arg R_VERSION={{R_VERSION}} --build-arg GITHUB_PAT="$GITHUB_PAT" --build-arg OS_VERSION={{OS_VERSION}} --build-arg RED_HAT_DEV_PW="$RED_HAT_DEV_PW" --platform linux/amd64,linux/arm64 -f docker/Containerfile-{{OS}} -t devxygmbh/rpkgs-build-env-{{OS}}:{{OS_VERSION}}-{{R_VERSION}} --push .; \
    else \
        docker buildx build --progress plain --build-arg R_VERSION={{R_VERSION}} --build-arg OS_VERSION={{OS_VERSION}} --build-arg GITHUB_PAT="$GITHUB_PAT" -f docker/Containerfile-{{OS}} --platform linux/amd64,linux/arm64 -t devxygmbh/rpkgs-build-env-{{OS}}:{{OS_VERSION}}-{{R_VERSION}} --push .; \
    fi

### JAGS takes forever to build in CI through buildx. Building the binary once and injecting it into the final image
# just image-jags alpine 3.20
# just image-jags alpine 3.21
# just image-jags alpine 3.22
# just image-jags ubuntu jammy
# just image-jags ubuntu noble
# just image-jags redhat 8
# just image-jags redhat 9
# just image-jags redhat 10
image-jags OS OS_VERSION:
    if echo "{{OS}}" | grep -qi "redhat"; then \
        docker buildx build --progress plain --platform linux/amd64,linux/arm64 --build-arg OS_VERSION={{OS_VERSION}} --build-arg RED_HAT_DEV_PW="$RED_HAT_DEV_PW" -f docker/Containerfile-{{OS}}-jags --push -t devxygmbh/{{OS}}-jags:{{OS_VERSION}} .; \
    else \
        docker buildx build --progress plain --platform linux/amd64,linux/arm64 --build-arg OS_VERSION={{OS_VERSION}} -f docker/Containerfile-{{OS}}-jags --push -t devxygmbh/{{OS}}-jags:{{OS_VERSION}} .;\
    fi

preview-docs:
    cd docs && quarto preview

publish-docs:
    cd docs && quarto render && rclone sync ./_site hetzner-s3://devxy-r-package-binaries-docs
