Changing to 0.0.0.0, fixing docker. Fixes #53

This commit is contained in:
Dessalines 2019-02-26 18:59:30 -08:00
parent 9558cc6a50
commit 2a1f5bc980
4 changed files with 8 additions and 6 deletions

View File

@ -1,7 +1,6 @@
FROM node:10-jessie as node FROM node:10-jessie as node
#If encounter Invalid cross-device error -run on host 'echo N | sudo tee /sys/module/overlay/parameters/metacopy' #If encounter Invalid cross-device error -run on host 'echo N | sudo tee /sys/module/overlay/parameters/metacopy'
ARG TORRENTS_CSV_ENDPOINT ARG TORRENTS_CSV_ENDPOINT
COPY server/ui /app/server/ui COPY server/ui /app/server/ui
RUN cd /app/server/ui && yarn && yarn build RUN cd /app/server/ui && yarn && yarn build

View File

@ -11,4 +11,5 @@ services:
- "8080:8080" - "8080:8080"
environment: environment:
TORRENTS_CSV_DB_FILE: /app/torrents.db TORRENTS_CSV_DB_FILE: /app/torrents.db
TORRENTS_CSV_FRONT_END_DIR: /app/dist TORRENTS_CSV_FRONT_END_DIR: /app/dist
TORRENTS_CSV_ENDPOINT: 0.0.0.0:8080

View File

@ -13,7 +13,7 @@ use std::ops::Deref;
use rusqlite::{Connection}; use rusqlite::{Connection};
fn main() { fn main() {
println!("Access me at http://localhost:8080"); println!("Access me at {}", endpoint());
server::new(|| { server::new(|| {
App::new() App::new()
.route("/service/search", http::Method::GET, search) .route("/service/search", http::Method::GET, search)
@ -22,10 +22,9 @@ fn main() {
"/static", "/static",
fs::StaticFiles::new(front_end_dir()) fs::StaticFiles::new(front_end_dir())
.unwrap() .unwrap()
// .index_file("index.html"),
) )
.finish() .finish()
}).bind("localhost:8080") }).bind(endpoint())
.unwrap() .unwrap()
.run(); .run();
} }
@ -42,6 +41,9 @@ fn torrents_db_file() -> String {
env::var("TORRENTS_CSV_DB_FILE").unwrap_or("../../torrents.db".to_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)] #[derive(Deserialize)]
struct SearchQuery { struct SearchQuery {
q: String, q: String,

View File

@ -2,7 +2,7 @@ require('dotenv').config();
const fs = require('fs'); const fs = require('fs');
exports.setEnv = function() { 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}';`; let env_line = `export const endpoint = '${endpoint}';`;
fs.writeFile("src/env.ts", env_line, function (err) { fs.writeFile("src/env.ts", env_line, function (err) {
console.log("Wrote src/env.ts:"); console.log("Wrote src/env.ts:");