Compare commits

...

5 Commits

Author SHA1 Message Date
3ec13397f4 Merge pull request 'refinement' (#1) from refinement into main
Reviewed-on: #1
2025-02-11 00:21:19 -03:00
f93fb91268 ci: add github workflow 2025-02-11 00:20:26 -03:00
84de4b07a2 ci: add dockerfile and edit docker compose
plus some optimizations
2025-02-11 00:18:58 -03:00
f7e861bc44 fix: adjust path variables in html 2025-02-10 23:48:13 -03:00
349723a770 feat: change to rust rocket project 2025-02-10 23:44:09 -03:00
36 changed files with 1871 additions and 11 deletions

31
.github/workflows/docker.yaml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login git.jabuxas.com -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build and push Docker image
run: |
docker build -t git.jabuxas.com/jabuxas/refinement:latest .
docker push git.jabuxas.com/jabuxas/refinement:latest
- name: Log out of Docker registry
run: docker logout git.jabuxas.com

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1756
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

14
Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "refinement"
version = "0.1.0"
edition = "2024"
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
panic = 'abort'
[dependencies]
rocket = "0.5.1"
rust-embed = "8.5.0"

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM rustlang/rust:nightly-slim
WORKDIR /app
COPY . .
RUN cargo build --release --bin refinement
CMD ["target/release/refinement"]

View File

@ -1,8 +1,8 @@
services:
web:
image: darkhttpd
web-server:
image: refinement
ports:
- "28080:80"
volumes:
- ./dev/:/var/www/htdocs:ro
- "8880:8000"
environment:
ROCKET_ADDRESS: 0.0.0.0
restart: unless-stopped

35
src/main.rs Normal file
View File

@ -0,0 +1,35 @@
#[macro_use]
extern crate rocket;
use std::{borrow::Cow, ffi::OsStr, path::PathBuf};
use rocket::{http::ContentType, response::content::RawHtml};
use rust_embed::Embed;
#[derive(Embed)]
#[folder = "static/"]
struct Asset;
#[get("/")]
fn index() -> Option<RawHtml<Cow<'static, [u8]>>> {
let asset = Asset::get("index.html")?;
Some(RawHtml(asset.data))
}
#[get("/dist/<file..>")]
fn dist(file: PathBuf) -> Option<(ContentType, Cow<'static, [u8]>)> {
let filename = file.display().to_string();
let asset = Asset::get(&filename)?;
let content_type = file
.extension()
.and_then(OsStr::to_str)
.and_then(ContentType::from_extension)
.unwrap_or(ContentType::Bytes);
Some((content_type, asset.data))
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index, dist])
}

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 491 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -5,11 +5,25 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="jabuxas' website" />
<title>jabuxas' hub</title>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />
<link href="style.css?version=1" rel="stylesheet" />
<link
rel="apple-touch-icon"
sizes="180x180"
href="/dist/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/dist/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/dist/favicon-16x16.png"
/>
<link rel="manifest" href="/dist/site.webmanifest" />
<link href="/dist/style.css?version=1" rel="stylesheet" />
</head>
<body>
@ -17,7 +31,7 @@
<div class="top-level">
<div>
<div class="image-container">
<img src="./images/maybe.jpg" alt="jabuxas' icon" />
<img src="/dist/images/maybe.jpg" alt="jabuxas' icon" />
</div>
<h2>jabuxas</h2>
</div>