From 350b7965718386e0439b5d4766605c1a4799e9d4 Mon Sep 17 00:00:00 2001 From: dacousb <53299044+dacousb@users.noreply.github.com> Date: Sun, 19 Sep 2021 21:03:01 +0200 Subject: [PATCH] Support Deployment to Heroku (#280) * Added heroku.yml * Added app.json * PORT as env var --- app.json | 42 ++++++++++++++++++++++++++++++++++++++++++ heroku.yml | 3 +++ src/main.rs | 5 +++-- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 app.json create mode 100644 heroku.yml diff --git a/app.json b/app.json new file mode 100644 index 0000000..8573671 --- /dev/null +++ b/app.json @@ -0,0 +1,42 @@ +{ + "name": "Libreddit", + "description": "Private front-end for Reddit", + "buildpacks": [ + { + "url": "https://github.com/emk/heroku-buildpack-rust" + }, + { + "url": "emk/rust" + } + ], + "stack": "container", + "env": { + "LIBREDDIT_DEFAULT_THEME": { + "required": false + }, + "LIBREDDIT_DEFAULT_FRONT_PAGE": { + "required": false + }, + "LIBREDDIT_DEFAULT_LAYOUT": { + "required": false + }, + "LIBREDDIT_DEFAULT_WIDE": { + "required": false + }, + "LIBREDDIT_DEFAULT_COMMENT_SORT": { + "required": false + }, + "LIBREDDIT_DEFAULT_POST_SORT": { + "required": false + }, + "LIBREDDIT_DEFAULT_SHOW_NSFW": { + "required": false + }, + "LIBREDDIT_USE_HLS": { + "required": false + }, + "LIBREDDIT_HIDE_HLS_NOTIFICATION": { + "required": false + } + } +} diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..8eec25b --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + web: Dockerfile diff --git a/src/main.rs b/src/main.rs index 786ce68..aa44e63 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,10 +133,11 @@ async fn main() { .get_matches(); let address = matches.value_of("address").unwrap_or("0.0.0.0"); - let port = matches.value_of("port").unwrap_or("8080"); + let port = std::env::var("PORT") + .unwrap_or_else(|_| matches.value_of("port").unwrap_or("8080").to_string()); let hsts = matches.value_of("hsts"); - let listener = [address, ":", port].concat(); + let listener = [address, ":", &port].concat(); println!("Starting Libreddit...");