Stash commit
This commit is contained in:
parent
4991467d32
commit
441e071074
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
**/Dockerfile
|
||||
**/target
|
||||
**/dist
|
||||
nginx*
|
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@ -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" ]
|
@ -1,6 +1,6 @@
|
||||
[default]
|
||||
address = "0.0.0.0"
|
||||
port = 80
|
||||
port = 8080
|
||||
|
||||
ip_header = "X-Real-IP"
|
||||
log_level = "normal"
|
||||
|
4
frontend/Trunk.toml
Normal file
4
frontend/Trunk.toml
Normal file
@ -0,0 +1,4 @@
|
||||
[build]
|
||||
minify = "on_release"
|
||||
[clean]
|
||||
cargo = true
|
@ -1,4 +1,4 @@
|
||||
|
||||
pub mod models;
|
||||
|
||||
pub static BASE: &'static str = env!("BASE");
|
||||
pub static BASE: &'static str = "/api";
|
||||
|
@ -45,7 +45,7 @@ impl Component for Chat {
|
||||
</div>
|
||||
<form class="chat">
|
||||
<div>
|
||||
<input type="textfield" required=true />
|
||||
<textarea type="textfield" autofocus=true required=true />
|
||||
</div>
|
||||
<div>
|
||||
<button onclick={
|
||||
|
@ -8,16 +8,16 @@ use allpaca::log;
|
||||
#[function_component]
|
||||
fn App() -> Html {
|
||||
html! {
|
||||
<>
|
||||
<div class="navbar">
|
||||
<nav::Bar></nav::Bar>
|
||||
</div>
|
||||
<models::List></models::List>
|
||||
<Chat></Chat>
|
||||
<div>
|
||||
<Fetcher></Fetcher>
|
||||
</div>
|
||||
</>
|
||||
<center>
|
||||
<div class="navbar">
|
||||
<nav::Bar></nav::Bar>
|
||||
</div>
|
||||
<models::List></models::List>
|
||||
<Chat></Chat>
|
||||
<div>
|
||||
<Fetcher></Fetcher>
|
||||
</div>
|
||||
</center>
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,20 @@ body {
|
||||
color: lime;
|
||||
}
|
||||
|
||||
.navbar, .model-list {
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.model-list > li {
|
||||
margin: 1vh;
|
||||
}
|
||||
|
||||
.chat textarea {
|
||||
resize: none;
|
||||
width: 69vw;
|
||||
height: 3vh;
|
||||
}
|
||||
|
||||
.chat {
|
||||
align-content: center;
|
||||
}
|
||||
|
45
init.sh
Executable file
45
init.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
echo "error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
worker_processes $WEB_WORKERS;
|
||||
user nginx;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" \$status \$body_bytes_sent "\$http_referer" "\$http_user_agent" "\$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
default_type application/octet-stream;
|
||||
include /etc/nginx/mime.types;
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
keepalive_timeout 65;
|
||||
gzip on;
|
||||
server {
|
||||
listen 80;
|
||||
location / {
|
||||
index index.html;
|
||||
root /srv/www;
|
||||
}
|
||||
location /api {
|
||||
rewrite /api/?(.*) /\$1 break;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_pass http://localhost:8080;
|
||||
}
|
||||
}
|
||||
}
|
||||
" > /etc/nginx/nginx.conf
|
||||
|
||||
echo "[default]
|
||||
ip_header = \"X-Real-IP\"
|
||||
log_level = \"normal\"
|
||||
workers = $WEB_WORKERS
|
||||
address = \"0.0.0.0\"
|
||||
port = 8080
|
||||
" > /Rocket.toml
|
||||
|
||||
oracle &
|
||||
nginx -g "daemon off;"
|
@ -35,7 +35,7 @@ http {
|
||||
location /api {
|
||||
rewrite /api/?(.*) /$1 break;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_pass http://backend:80;
|
||||
proxy_pass http://backend:8080;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user