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..de90b6a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,11 @@ services: build: context: . args: - TORRENTS_CSV_ENDPOINT: http://0.0.0.0:8080 + TORRENTS_CSV_ENDPOINT: http://0.0.0.0:8088 command: /bin/sh -c /app/torrents-csv-service ports: - "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:");