Something went wrong. Try again.
A Haskell Webserver Template
Something went wrong. Try again.
3.0 kB · 99 lines
Just
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100# List this menu and exithelp: just --justfile "{{ justfile_directory() }}/application/justfile" --list# Format the appformat: #!/usr/bin/env amber main(args) { cd "{{ justfile_directory() }}" echo "===== Formatting =====" $ fourmolu -qi \ --no-cabal \ -o -XDefaultSignatures \ -o -XDeriveGeneric \ -o -XDeriveAnyClass \ -o -XFlexibleContexts \ -o -XFlexibleInstances \ -o -XGADTs \ -o -XInstanceSigs \ -o -XLambdaCase \ -o -XMultiParamTypeClasses \ -o -XMultiWayIf \ -o -XOverloadedLabels \ -o -XOverloadedLists \ -o -XOverloadedRecordDot \ -o -XOverloadedStrings \ -o -XPatternSynonyms \ -o -XStandaloneDeriving \ -o -XTemplateHaskell \ -o -XTupleSections \ -o -XTypeApplications \ -o -XTypeFamilies \ -o -XTypeSynonymInstances \ -o -XViewPatterns \ "{{ justfile_directory() }}/application" \ > /dev/null $ failed { echo "Failed to run fourmolu: {status}" fail } $ stylish-haskell -ir \ "{{ justfile_directory() }}/application" \ > /dev/null $ failed { echo "Failed to run stylish-haskell: {status}" fail } $ cabal-fmt --inplace "{{ justfile_directory() }}/webserver.cabal" \ > /dev/null $ failed { echo "Failed to run cabal-fmt: {status}" fail } $ nixfmt "{{ justfile_directory() }}/shell.nix" \ "{{ justfile_directory() }}/nix/oci-image.nix" \ > /dev/null $ failed { echo "Failed to run nixfmt: {status}" fail } $ just -q --unstable --fmt \ > /dev/null $ failed { echo "Failed to run just: {status}" fail } echo "Done" exit 0 }# Format, then build the appbuild: format #!/usr/bin/env amber main(args) { cd "{{ justfile_directory() }}" echo "===== Building App =====" $ dotenvx run --env-file {{ justfile_directory() }}/.env.development -- cabal build webserver $ failed { echo "Failed to build webserver: {status}" fail } echo "Done" exit 0 }# Format, build, then run the apprun: build #!/usr/bin/env amber main(args) { cd "{{ justfile_directory() }}" echo "===== Starting =====" trust $ dotenvx run --env-file \ {{ justfile_directory() }}/.env.development \ -- watchexec -r -e hs \ -- cabal run webserver $ exit 0 }# Build OCI image for productionoci-build: nix-build {{ justfile_directory() }}/nix/oci-image.nix -o result-image# Load OCI image into dockeroci-load: oci-build docker load < result-image