stalled on docker nginx curfuffle

This commit is contained in:
Pagwin 2024-02-18 03:02:19 -05:00
parent 41dc3ff223
commit cf3787abfd
7 changed files with 96 additions and 1373 deletions

View file

@ -1,26 +1,18 @@
FROM debian:latest FROM node:latest as build
RUN apt-get update && apt-get upgrade && apt-get -y install wget xz-utils RUN mkdir -p /work
RUN wget https://factorio.com/get-download/stable/headless/linux64 -O factorio-stable.tar.xz WORKDIR /work
RUN tar xf factorio-stable.tar.xz COPY . .
WORKDIR /factorio RUN npm i
RUN useradd -M factorio RUN npm run build
RUN chown -R factorio /factorio FROM nginx:1.25-alpine
USER factorio RUN apk update && apk upgrade
RUN mkdir -p saves COPY --from=build /work/dist /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/nginx.conf
VOLUME ["/factorio/saves"]
EXPOSE 34197/udp
EXPOSE 27015/tcp
ENTRYPOINT ["/factorio/bin/x64/factorio"]
CMD ["/factorio/bin/x64/factorio", "--start-server", "/factorio/saves/default.zip"]

32
BBB_frontend/nginx.conf Normal file
View file

@ -0,0 +1,32 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /api/ {
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
proxy_send_timeout 60s;
proxy_pass http://backend/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}

1349
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@ edition = "2021"
anyhow = "1.0.79" anyhow = "1.0.79"
chrono = "0.4.34" chrono = "0.4.34"
reqwest = "0.11.24" reqwest = "0.11.24"
sea-orm = "0.12.14" #sea-orm = "0.12.14"
serde = { version = "1.0.196", features = ["derive"] } serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113" serde_json = "1.0.113"
tide = "0.16.0" tide = "0.16.0"

View file

@ -1,26 +1,26 @@
FROM rust:latest as rust
WORKDIR /usr/src/myapp
COPY . .
RUN mkdir -p "install"
RUN cargo install --path . --root install
FROM debian:latest FROM debian:latest
RUN apt-get update && apt-get upgrade && apt-get -y install wget xz-utils RUN apt-get update && apt-get upgrade && apt-get install -y openssl
RUN wget https://factorio.com/get-download/stable/headless/linux64 -O factorio-stable.tar.xz WORKDIR /BBB_api
RUN tar xf factorio-stable.tar.xz RUN useradd -M BBB_api
WORKDIR /factorio RUN chown -R BBB_api /BBB_api
RUN useradd -M factorio USER BBB_api
RUN chown -R factorio /factorio EXPOSE 80
USER factorio COPY --from=rust /usr/src/myapp/install/bin/bus_api /BBB_api
COPY GOOGLE_API_KEY /BBB_api
RUN mkdir -p saves ENTRYPOINT ["/BBB_api/bus_api"]
VOLUME ["/factorio/saves"] CMD ["/BBB_api/bus_api"]
EXPOSE 34197/udp
EXPOSE 27015/tcp
ENTRYPOINT ["/factorio/bin/x64/factorio"]
CMD ["/factorio/bin/x64/factorio", "--start-server", "/factorio/saves/default.zip"]

14
docker-compose.yml Normal file
View file

@ -0,0 +1,14 @@
version: "3.3"
services:
backend:
build: .
ports:
- 9090:80
restart: unless-stopped
frontend:
build: BBB_frontend
restart: unless-stopped
ports:
- 8080:80
depends_on:
- backend

View file

@ -15,13 +15,19 @@ mod path_calc;
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
let mut app = tide::with_state(state::State::new().await?); let mut app = tide::with_state(state::State::new().await?);
app.at("/path").get(transit_path); app.at("/path").get(transit_path);
app.at("/time_to_arrive").get(transit_estimate); app.at("/time_to_arrive").get(transit_estimate);
app.at("/route_draw").get(bus_route_draw); app.at("/route_draw").get(bus_route_draw);
app.at("/").get(|_|async {
println!("get");
Ok(tide::Response::from("OK"))
});
app.at("/*").get(|_|async{
Ok(tide::Response::from("???"))
});
// TODO: change to 0.0.0.0 when docker image done println!("READY!");
app.listen("127.0.0.1:8080").await?; app.listen("0.0.0.0:80").await?;
Ok(()) Ok(())
} }