2024-10-21 07:03:51 +02:00
|
|
|
# Written and tested 2024-10-21 with just 1.34.0 on Fedora 41
|
|
|
|
|
2024-10-21 05:15:37 +02:00
|
|
|
# See: https://github.com/bigskysoftware/htmx/releases
|
|
|
|
# For static latest: https://github.com/bigskysoftware/htmx/releases/latest/download/htmx.min.js
|
|
|
|
htmx-ver := "2.0.3"
|
|
|
|
htmx-sha256sum := "491955cd1810747d7d7b9ccb936400afb760e06d25d53e4572b64b6563b2784e"
|
|
|
|
htmx-file := "htmx.min.js"
|
|
|
|
htmx-url := "https://github.com/bigskysoftware/htmx/releases/download/v" + htmx-ver / htmx-file
|
|
|
|
|
2024-11-01 16:25:34 +01:00
|
|
|
van-ver := "1.5.2"
|
|
|
|
van-sha256sum := "cf0027d9061fb10dc3c7055e0d8e39f3f75a30ab0cf00c3f65933d3f7e3b08e6"
|
|
|
|
van-file := "van.min.js"
|
|
|
|
van-url := "https://vanjs.org/code/" + "van-" + van-ver + ".min.js"
|
|
|
|
|
2024-10-21 05:15:37 +02:00
|
|
|
[doc("Run the server")]
|
2024-11-01 16:25:34 +01:00
|
|
|
run: get-htmx get-van
|
2024-09-10 02:08:20 +02:00
|
|
|
go run ./http-serve.go
|
|
|
|
|
2024-10-21 05:15:37 +02:00
|
|
|
[doc("Build a static binary with content bundled")]
|
2024-11-01 16:25:34 +01:00
|
|
|
build: get-htmx get-van
|
2024-10-21 05:15:37 +02:00
|
|
|
go build -o build/htmx-server ./http-serve.go
|
|
|
|
|
|
|
|
# TODO: Maybe use shasum instead for FreeBSD support
|
|
|
|
[doc("Download the HTMX release")]
|
2024-09-10 02:07:53 +02:00
|
|
|
get-htmx:
|
2024-10-21 05:15:37 +02:00
|
|
|
@test -f htmx.min.js || echo "Getting HTMX..." && curl --silent -O -lSSL {{htmx-url}}
|
|
|
|
@sha256sum -c <<< "{{htmx-sha256sum}} {{htmx-file}}" || (echo "Checksum failed, check Justfile" && exit 1)
|
2024-09-10 02:07:53 +02:00
|
|
|
|
2024-11-01 16:25:34 +01:00
|
|
|
get-van:
|
|
|
|
@test -f {{van-file}} || echo "Getting Van..." && curl --silent -o {{van-file}} -lSSL {{van-url}}
|
|
|
|
@sha256sum -c <<< "{{van-sha256sum}} {{van-file}}" || (echo "Checksum failed, check Justfile" && exit 1)
|
|
|
|
|
2024-10-21 05:15:37 +02:00
|
|
|
[doc("Cleanup source tree")]
|
|
|
|
[confirm("Are you sure? [y/N]:")]
|
2024-10-21 07:03:51 +02:00
|
|
|
clean: clean-container
|
2024-10-21 05:15:37 +02:00
|
|
|
rm -rf .go
|
|
|
|
rm -rf build
|
|
|
|
rm -f htmx.min.js
|
2024-11-01 16:25:34 +01:00
|
|
|
rm -f van-*.min.js
|
2024-10-21 07:03:51 +02:00
|
|
|
|
|
|
|
# Build the container
|
|
|
|
build-container: get-htmx
|
|
|
|
podman build -t htmx-demo -f container/Containerfile .
|
|
|
|
|
|
|
|
# Spin up a production container
|
|
|
|
run-container:
|
|
|
|
# Build the image if it doesnt exist
|
|
|
|
podman image exists htmx-demo || just build-container
|
|
|
|
|
|
|
|
# Stop existing if its running
|
|
|
|
podman container exists htmx-demo-container && podman stop htmx-demo-container || true
|
|
|
|
|
|
|
|
# Run the container
|
|
|
|
podman run -d --rm --name htmx-demo-container -p 8085:8080 htmx-demo
|
|
|
|
@echo "Server running on http://localhost:8085"
|
|
|
|
|
|
|
|
# Remove containers, images and dependencies for container build
|
|
|
|
clean-container:
|
|
|
|
podman container exists htmx-demo-container && podman stop htmx-demo-container || true
|
|
|
|
podman image exists htmx-demo && podman rmi htmx-demo || true
|
|
|
|
podman image exists golang && podman rmi golang || true
|
|
|
|
podman image exists alpine && podman rmi alpine || true
|
|
|
|
podman builder prune -f
|