diff --git a/.gitignore b/.gitignore index 600d2d3..f416718 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -.vscode \ No newline at end of file +.vscode +target +.env +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c678117 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "spfn-website" +version = "0.1.0" +edition = "2024" + +[dependencies] +axum = "0.8.9" +dotenvy = "0.15.7" +tokio = { version = "1.52.3", features = ["full"] } +tower-http = { version = "0.7.0", features = ["fs"] } diff --git a/Dockerfile b/Dockerfile index 9165e58..955f18e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,28 @@ # syntax=docker/dockerfile:1 -FROM nginx:alpine +FROM rust:alpine AS builder -WORKDIR /usr/share/nginx/html +RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld + +WORKDIR /app + +COPY Cargo.toml ./ +RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo fetch COPY . . -RUN rm -rf .git +ENV SQLX_OFFLINE=true -EXPOSE 80 +RUN OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld" cargo build --release --target x86_64-unknown-linux-musl -CMD ["nginx", "-g", "daemon off;"] +FROM alpine:latest AS final + +RUN apk add --no-cache ca-certificates +RUN update-ca-certificates + +WORKDIR / + +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/spfn-website /spfn-website +COPY --from=builder /app/static /static + +ENTRYPOINT ["/spfn-website"] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..fe9c2ed --- /dev/null +++ b/src/main.rs @@ -0,0 +1,25 @@ +use std::env; +use axum::Router; +use tower_http::services::ServeDir; +use dotenvy::dotenv; + +#[tokio::main] +async fn main() { + dotenv().ok(); + + let host = env::var("APP_HOST").unwrap_or("0.0.0.0".into()); + let port = env::var("APP_PORT").unwrap_or("80".into()); + + let app = Router::new() + .fallback_service(ServeDir::new("static")); + + let listener = tokio::net::TcpListener::bind(format!("{}:{}", host, port)) + .await + .unwrap(); + + println!("Website Hosting with Host {} and Port {}", host, port); + + axum::serve(listener, app) + .await + .unwrap(); +} diff --git a/account/index.html b/static/account/index.html similarity index 100% rename from account/index.html rename to static/account/index.html diff --git a/account/login/index.html b/static/account/login/index.html similarity index 100% rename from account/login/index.html rename to static/account/login/index.html diff --git a/css/style.css b/static/css/style.css similarity index 100% rename from css/style.css rename to static/css/style.css diff --git a/downloads/index.html b/static/downloads/index.html similarity index 100% rename from downloads/index.html rename to static/downloads/index.html diff --git a/downloads/network_services.xml b/static/downloads/network_services.xml similarity index 100% rename from downloads/network_services.xml rename to static/downloads/network_services.xml diff --git a/guides/index.html b/static/guides/index.html similarity index 100% rename from guides/index.html rename to static/guides/index.html diff --git a/index.html b/static/index.html similarity index 100% rename from index.html rename to static/index.html diff --git a/js/accounts.js b/static/js/accounts.js similarity index 100% rename from js/accounts.js rename to static/js/accounts.js diff --git a/js/guides.js b/static/js/guides.js similarity index 100% rename from js/guides.js rename to static/js/guides.js diff --git a/js/home.js b/static/js/home.js similarity index 100% rename from js/home.js rename to static/js/home.js diff --git a/js/login.js b/static/js/login.js similarity index 100% rename from js/login.js rename to static/js/login.js diff --git a/md/common-errors.md b/static/md/common-errors.md similarity index 100% rename from md/common-errors.md rename to static/md/common-errors.md diff --git a/md/install-cemu.md b/static/md/install-cemu.md similarity index 100% rename from md/install-cemu.md rename to static/md/install-cemu.md diff --git a/md/install-wiiu.md b/static/md/install-wiiu.md similarity index 100% rename from md/install-wiiu.md rename to static/md/install-wiiu.md diff --git a/md/troubleshoot-cemu.md b/static/md/troubleshoot-cemu.md similarity index 100% rename from md/troubleshoot-cemu.md rename to static/md/troubleshoot-cemu.md diff --git a/md/troubleshoot-wiiu.md b/static/md/troubleshoot-wiiu.md similarity index 100% rename from md/troubleshoot-wiiu.md rename to static/md/troubleshoot-wiiu.md diff --git a/res/img/bloxerhd.png b/static/res/img/bloxerhd.png similarity index 100% rename from res/img/bloxerhd.png rename to static/res/img/bloxerhd.png diff --git a/res/img/ceantix.png b/static/res/img/ceantix.png similarity index 100% rename from res/img/ceantix.png rename to static/res/img/ceantix.png diff --git a/res/img/discord.png b/static/res/img/discord.png similarity index 100% rename from res/img/discord.png rename to static/res/img/discord.png diff --git a/res/img/fj.png b/static/res/img/fj.png similarity index 100% rename from res/img/fj.png rename to static/res/img/fj.png diff --git a/res/img/kinnay.png b/static/res/img/kinnay.png similarity index 100% rename from res/img/kinnay.png rename to static/res/img/kinnay.png diff --git a/res/img/mii-placeholder.png b/static/res/img/mii-placeholder.png similarity index 100% rename from res/img/mii-placeholder.png rename to static/res/img/mii-placeholder.png diff --git a/res/img/pretendo.png b/static/res/img/pretendo.png similarity index 100% rename from res/img/pretendo.png rename to static/res/img/pretendo.png diff --git a/res/img/purplepote.png b/static/res/img/purplepote.png similarity index 100% rename from res/img/purplepote.png rename to static/res/img/purplepote.png diff --git a/res/img/rusticmaple.png b/static/res/img/rusticmaple.png similarity index 100% rename from res/img/rusticmaple.png rename to static/res/img/rusticmaple.png diff --git a/res/img/spfn.png b/static/res/img/spfn.png similarity index 100% rename from res/img/spfn.png rename to static/res/img/spfn.png diff --git a/res/img/splatfestival.png b/static/res/img/splatfestival.png similarity index 100% rename from res/img/splatfestival.png rename to static/res/img/splatfestival.png