From 441e0710743d298905a707323297fe4ef07aa35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sivert=20V=2E=20S=C3=A6ther?= Date: Thu, 7 Nov 2024 14:19:09 +0100 Subject: [PATCH] Stash commit --- .dockerignore | 4 +++ Dockerfile | 27 ++++++++++++++++++++ backend/Rocket.toml | 2 +- frontend/Trunk.toml | 4 +++ frontend/src/api/mod.rs | 2 +- frontend/src/components/chat.rs | 2 +- frontend/src/main.rs | 20 +++++++-------- frontend/styles.css | 12 ++++++++- init.sh | 45 +++++++++++++++++++++++++++++++++ nginx.conf | 2 +- 10 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 frontend/Trunk.toml create mode 100755 init.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..39f0ee3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +**/Dockerfile +**/target +**/dist +nginx* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a85a298 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM rust:slim AS build + +RUN rustup default nightly +RUN rustup target add wasm32-unknown-unknown +RUN cargo install cargo-watch trunk + +RUN apt update && apt install -y\ + pkg-config librust-openssl-dev + +ADD ./ / + +WORKDIR /backend +RUN cargo build --release + +WORKDIR /frontend +RUN trunk build --release + +FROM nginx:latest + +COPY --from=build /target/release/oracle /bin +COPY --from=build /frontend/dist /srv/www +ADD init.sh /bin/init.sh + +ENV WEB_WORKERS=4 +EXPOSE 80 + +CMD [ "init.sh" ] \ No newline at end of file diff --git a/backend/Rocket.toml b/backend/Rocket.toml index 6925c31..19c6815 100644 --- a/backend/Rocket.toml +++ b/backend/Rocket.toml @@ -1,6 +1,6 @@ [default] address = "0.0.0.0" -port = 80 +port = 8080 ip_header = "X-Real-IP" log_level = "normal" diff --git a/frontend/Trunk.toml b/frontend/Trunk.toml new file mode 100644 index 0000000..0ecc4a3 --- /dev/null +++ b/frontend/Trunk.toml @@ -0,0 +1,4 @@ +[build] +minify = "on_release" +[clean] +cargo = true diff --git a/frontend/src/api/mod.rs b/frontend/src/api/mod.rs index a69adda..d418065 100644 --- a/frontend/src/api/mod.rs +++ b/frontend/src/api/mod.rs @@ -1,4 +1,4 @@ pub mod models; -pub static BASE: &'static str = env!("BASE"); +pub static BASE: &'static str = "/api"; diff --git a/frontend/src/components/chat.rs b/frontend/src/components/chat.rs index 37b5dec..c006f79 100644 --- a/frontend/src/components/chat.rs +++ b/frontend/src/components/chat.rs @@ -45,7 +45,7 @@ impl Component for Chat {
- +