diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml deleted file mode 100644 index edef09f..0000000 --- a/.forgejo/workflows/deploy.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: deploy - -on: - push: - branches: - - master - -jobs: - deploy: - runs-on: host - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - registry: git.hydrar.de - username: ${{ secrets.registry_user }} - password: ${{ secrets.registry_password }} - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: git.hydrar.de/jmarya/me-site:latest diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..bc17b6b --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,25 @@ +name: deploy + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Docker + run: curl -fsSL https://get.docker.com | sh + + - name: Log in to Docker registry + run: echo "${{ secrets.registry_password }}" | docker login -u "${{ secrets.registry_user }}" --password-stdin git.hydrar.de + + - name: Build and push Docker image + run: | + docker build -t git.hydrar.de/jmarya/me-site:latest -t git.hydrar.de/jmarya/me-site:latest-amd64 . + docker push git.hydrar.de/jmarya/me-site:latest diff --git a/Dockerfile b/Dockerfile index babdf59..44fd850 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,10 @@ WORKDIR /app RUN cargo build --release -FROM debian:buster +FROM archlinux -RUN apt update && apt upgrade -y -RUN apt install -y gnupg ca-certificates openssl +RUN pacman -Syu --noconfirm +RUN pacman -S --noconfirm gnupg ca-certificates openssl-1.1 COPY --from=builder /app/target/release/me-site /me-site COPY ./rocket.toml /rocket.toml diff --git a/src/pages/bootstrap.rs b/src/pages/bootstrap.rs index 4935ae9..b2a45da 100644 --- a/src/pages/bootstrap.rs +++ b/src/pages/bootstrap.rs @@ -11,17 +11,21 @@ async fn download_file(url: &str, file: &str) { #[get("/bootstrap.min.css")] pub async fn bootstrap_css() -> Option { - NamedFile::open("./cache/bootstrap.min.css").await.ok() + NamedFile::open("./cache/bootstrap.mi.await.ok()n.css") + .await + .ok() } #[get("/bootstrap-icons.css")] pub async fn bootstrap_icons() -> Option { - NamedFile::open("./cache/bootstrap-icons.css").await.ok() + NamedFile::open("./cache/bootstrap-icon.await.ok()s.css") + .await + .ok() } #[get("/bootstrap.bundle.min.js")] pub async fn bootstrap_js() -> Option { - NamedFile::open("./cache/bootstrap.bundle.min.js") + NamedFile::open("./cache/bootstrap.b.await.ok()undle.min.js") .await .ok() } diff --git a/src/pages/html.rs b/src/pages/html.rs index 7ded392..fe3b135 100644 --- a/src/pages/html.rs +++ b/src/pages/html.rs @@ -1,6 +1,5 @@ use crate::config::Config; use maud::{html, PreEscaped, DOCTYPE}; -use rocket::http::ContentType; use rocket::request::{FromRequest, Outcome, Request}; pub enum RequestClient { @@ -25,7 +24,7 @@ impl<'r> FromRequest<'r> for RequestClient { pub fn is_browser(req: &Request) -> bool { let ua = req .headers() - .get("User-Agent") + .get("usesr-agent") .next() .unwrap() .to_lowercase(); @@ -38,7 +37,7 @@ pub async fn build_site( disable_color: bool, shadow: bool, config: &Config, -) -> (ContentType, String) { +) -> String { let mut c_class = "bg-dark text-white justify-content-center text-center".to_string(); let mut c_style = String::new(); let mut g_style = "a {text-decoration: none; font-weight: bold; color: white}".to_string(); @@ -65,10 +64,7 @@ pub async fn build_site( }; }; - ( - ContentType::HTML, - build_site_from_body(title, &body.into_string()), - ) + build_site_from_body(title, &body.into_string()) } pub fn build_site_from_body(title: &str, body: &str) -> String { diff --git a/src/pages/index.rs b/src/pages/index.rs index cb7e40f..a054a9b 100644 --- a/src/pages/index.rs +++ b/src/pages/index.rs @@ -1,6 +1,5 @@ use crate::config; use maud::{html, PreEscaped}; -use rocket::http::ContentType; use rocket::{form::Form, get, post, response::Redirect, uri, FromForm, State}; use serde::{Deserialize, Serialize}; @@ -20,7 +19,7 @@ pub async fn message_post(msg: Form, config: &State } #[get("/message")] -pub async fn message_page(config: &State) -> (ContentType, String) { +pub async fn message_page(config: &State) -> String { let post_uri = uri!(message_post).to_string(); let resp = html! { @@ -40,10 +39,7 @@ pub async fn message_page(config: &State) -> (ContentType, Strin } #[get("/mirrors.txt")] -pub async fn mirrors( - r: RequestClient, - config: &State, -) -> Option<(ContentType, String)> { +pub async fn mirrors(r: RequestClient, config: &State) -> Option { if let Ok(mirror_file) = std::fs::File::open("./config/mirrors.txt") { let content = std::io::read_to_string(mirror_file).ok()?; if matches!(r, RequestClient::Browser) { @@ -57,17 +53,14 @@ pub async fn mirrors( return Some(build_site(resp.into_string(), "Mirrors", false, true, config).await); } - return Some((ContentType::Plain, content)); + return Some(content); } None } #[get("/public_key")] -pub async fn public_key( - r: RequestClient, - config: &State, -) -> Option<(ContentType, String)> { +pub async fn public_key(r: RequestClient, config: &State) -> Option { if matches!(r, RequestClient::Browser) { let host = config.base_url(); let key = std::io::read_to_string( @@ -97,7 +90,7 @@ pub async fn public_key( if let Ok(key_f) = std::fs::File::open("./config/pub.key") { if let Ok(key_data) = std::io::read_to_string(key_f) { - return Some((ContentType::Plain, key_data)); + return Some(key_data); } } @@ -167,7 +160,7 @@ fn build_donation_block(conf: &config::Config) -> String { } #[get("/")] -pub async fn index(conf: &State) -> (ContentType, String) { +pub async fn index(conf: &State) -> String { let information_block = build_information_block(conf); let contact_block = build_contact_block(conf); let donation_block = build_donation_block(conf);