diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..335d6dc --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: build deploy + +help: ## Show this help. + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +build: ## Build static binary and put it in the functions directory. + @cargo build --release + @mkdir -p functions + @cp target/release/lupt functions + +deploy: build ## Deploy the site using Netlify's CLI + @netlify deploy --prod \ No newline at end of file diff --git a/functions b/functions deleted file mode 100755 index 54625ae..0000000 --- a/functions +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/bash -lupt/target/release/lupt -s ./static -a $URL \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index 29eb192..311c5e7 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,20 +1,4 @@ -# example netlify.toml -[build] - command = "cargo build --release" - functions = "functions" - - ## Uncomment to use this redirect for Single Page Applications like create-react-app. - ## Not needed for static site generators. - #[[redirects]] - # from = "/*" - # to = "/index.html" - # status = 200 - - ## (optional) Settings for Netlify Dev - ## https://github.com/netlify/cli/blob/master/docs/netlify-dev.md#project-detection - #[dev] - # command = "yarn start" # Command to start your dev server - # port = 3000 # Port that the dev server will be listening on - # publish = "dist" # Folder with the static content for _redirect file - - ## more info on configuring this file: https://www.netlify.com/docs/netlify-toml-reference/ +[build] +command = "make build" +publish = "static" +functions = "functions" diff --git a/src/config.rs b/src/config.rs index d84e2e6..3985faf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,16 @@ pub struct Config { impl Config { pub fn new() -> Self { + let bind_address = std::env::var("URL"); + let static_path = std::env::var("STATIC_PATH"); + + if bind_address.is_ok() && static_path.is_ok() { + return Config { + static_path: static_path.unwrap(), + bind_address: bind_address.unwrap() + }; + } + let matches = App::new("Lupt (लुप्त)") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS"))