From 2a1f5bc980d61a05ead94130d245b2ee7d34fe47 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 26 Feb 2019 18:59:30 -0800 Subject: [PATCH] Changing to 0.0.0.0, fixing docker. Fixes #53 --- Dockerfile | 1 - docker-compose.yml | 3 ++- server/service/src/main.rs | 8 +++++--- server/ui/set_env.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 32c1b88..4ccf20a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM node:10-jessie as node #If encounter Invalid cross-device error -run on host 'echo N | sudo tee /sys/module/overlay/parameters/metacopy' ARG TORRENTS_CSV_ENDPOINT - COPY server/ui /app/server/ui RUN cd /app/server/ui && yarn && yarn build diff --git a/docker-compose.yml b/docker-compose.yml index d445ebe..e712cea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,4 +11,5 @@ services: - "8080:8080" environment: TORRENTS_CSV_DB_FILE: /app/torrents.db - TORRENTS_CSV_FRONT_END_DIR: /app/dist \ No newline at end of file + TORRENTS_CSV_FRONT_END_DIR: /app/dist + TORRENTS_CSV_ENDPOINT: 0.0.0.0:8080 diff --git a/server/service/src/main.rs b/server/service/src/main.rs index 578939f..f1df4db 100644 --- a/server/service/src/main.rs +++ b/server/service/src/main.rs @@ -13,7 +13,7 @@ use std::ops::Deref; use rusqlite::{Connection}; fn main() { - println!("Access me at http://localhost:8080"); + println!("Access me at {}", endpoint()); server::new(|| { App::new() .route("/service/search", http::Method::GET, search) @@ -22,10 +22,9 @@ fn main() { "/static", fs::StaticFiles::new(front_end_dir()) .unwrap() - // .index_file("index.html"), ) .finish() - }).bind("localhost:8080") + }).bind(endpoint()) .unwrap() .run(); } @@ -42,6 +41,9 @@ fn torrents_db_file() -> String { env::var("TORRENTS_CSV_DB_FILE").unwrap_or("../../torrents.db".to_string()) } +fn endpoint() -> String { + env::var("TORRENTS_CSV_ENDPOINT").unwrap_or("0.0.0.0:8080".to_string()) +} #[derive(Deserialize)] struct SearchQuery { q: String, diff --git a/server/ui/set_env.js b/server/ui/set_env.js index 73734e0..a6fce7b 100644 --- a/server/ui/set_env.js +++ b/server/ui/set_env.js @@ -2,7 +2,7 @@ require('dotenv').config(); const fs = require('fs'); exports.setEnv = function() { - let endpoint = (process.env.TORRENTS_CSV_ENDPOINT) ? process.env.TORRENTS_CSV_ENDPOINT : "http://localhost:8080"; + let endpoint = (process.env.TORRENTS_CSV_ENDPOINT) ? process.env.TORRENTS_CSV_ENDPOINT : "http://0.0.0.0:8080"; let env_line = `export const endpoint = '${endpoint}';`; fs.writeFile("src/env.ts", env_line, function (err) { console.log("Wrote src/env.ts:");