Parcourir la source

run the bot on port 80 inside the docker container

Pietro Albini il y a 6 ans
Parent
commit
4ec6c12570
2 fichiers modifiés avec 9 ajouts et 1 suppressions
  1. 1 0
      Dockerfile
  2. 8 1
      src/main.rs

+ 1 - 0
Dockerfile

@@ -52,4 +52,5 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
     ca-certificates
 
 COPY --from=build /tmp/source/target/release/triagebot /usr/local/bin/
+ENV TRIAGEBOT_PORT=80
 CMD ["triagebot"]

+ 8 - 1
src/main.rs

@@ -117,7 +117,14 @@ fn main() {
     let username = Arc::new(User::current(&gh).unwrap().login);
     let mut registry = HandleRegistry::new();
     handlers::register_all(&mut registry, gh.clone(), username);
-    rocket::ignite()
+
+    let mut config = rocket::Config::active().unwrap();
+    config.set_port(
+        env::var("TRIAGEBOT_PORT")
+            .map(|port| port.parse().unwrap())
+            .unwrap_or(8000),
+    );
+    rocket::custom(config)
         .manage(gh)
         .manage(registry)
         .mount("/", routes![webhook])