Compare commits

...

5 Commits

Author SHA1 Message Date
06701ea7be feat: require subcommand 2023-04-03 22:48:49 +02:00
502b9023d3 feat: add favicon and add plausible 2023-04-03 22:27:24 +02:00
079a076925 feat: fix ci 2023-04-03 14:57:07 +02:00
9565aa03b8 Merge pull request #1 from kjuulh/renovate/configure
Configure Renovate
2023-03-08 08:47:43 +01:00
Renovate Bot
044878d78e Add renovate.json 2023-03-07 22:57:51 +00:00
13 changed files with 840 additions and 398 deletions

1
.gitignore vendored
View File

@@ -11,3 +11,4 @@ node_modules/
test-results/
end2end/playwright-report/
playwright/.cache/
.env

1060
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ chrono = { version = "0.4.23", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
[package]
name = "ssr_modes_axum"
name = "ssr_modes"
version = "0.1.0"
edition = "2021"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -6,8 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dagger-sdk = "0.2.15"
dagger-sdk = "0.2.20"
eyre = "0.6.8"
color-eyre = "0.6.2"
tokio = { version = "1.26.0", features = ["full"] }
tokio = { version = "1.27.0", features = ["full"] }
chrono.workspace = true
dotenv = "0.15.0"

View File

@@ -1,6 +1,7 @@
#[tokio::main]
async fn main() -> eyre::Result<()> {
let rust_image = "rustlang/rust:nightly";
let _ = dotenv::dotenv();
let rust_image = "docker.io/rustlang/rust:nightly";
let client = dagger_sdk::connect().await?;
@@ -14,12 +15,18 @@ async fn main() -> eyre::Result<()> {
let minio_url = "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz";
let sccache_download_cache = client.cache_volume("sccache_download");
let cargo_cache = client.cache_volume("cargo_cache");
// Main container
let rust_base = client
.container()
.from(rust_image)
.with_exec(vec!["apt-get", "update"])
.with_exec(vec!["apt-get", "install", "--yes", "libpq-dev", "wget"])
.with_exec(vec!["mkdir", "-p", "/src/downloads"])
.with_workdir("/src/downloads")
.with_mounted_cache("/src/downloads", sccache_download_cache.id().await?)
.with_exec(vec!["wget", minio_url])
.with_exec(vec![
"tar",
@@ -44,6 +51,8 @@ async fn main() -> eyre::Result<()> {
.with_env_variable("SCCACHE_BUCKET", "sccache")
.with_env_variable("SCCACHE_REGION", "auto")
.with_env_variable("SCCACHE_ENDPOINT", "https://api-minio.front.kjuulh.io")
.with_mounted_cache("~/.cargo", cargo_cache.id().await?)
.with_exec(vec!["rustup", "target", "add", "wasm32-unknown-unknown"])
.with_exec(vec!["cargo", "install", "cargo-chef"])
.with_exec(vec!["cargo", "install", "cargo-leptos"])
.with_workdir("/app");
@@ -53,8 +62,10 @@ async fn main() -> eyre::Result<()> {
eyre::bail!("could not build base");
}
let target_cache = client.cache_volume("target_cache");
let rust_prepare = rust_base
.with_mounted_directory(".", workdir.id().await?)
.with_mounted_cache("target", target_cache.id().await?)
.with_exec(vec![
"cargo",
"chef",
@@ -68,6 +79,8 @@ async fn main() -> eyre::Result<()> {
eyre::bail!("could not build prepare");
}
let target_rust_cache = client.cache_volume("target_rust_cache");
let rust_cacher = rust_base
.with_exec(vec!["apt", "update"])
.with_exec(vec![
@@ -83,7 +96,7 @@ async fn main() -> eyre::Result<()> {
"/recipe.json",
rust_prepare.file("./recipe.json").id().await?,
)
.with_mounted_directory(".", workdir.id().await?)
.with_mounted_cache("target", target_rust_cache.id().await?)
.with_exec(vec![
"cargo",
"chef",
@@ -91,36 +104,40 @@ async fn main() -> eyre::Result<()> {
"--release",
"--recipe-path",
"/recipe.json",
]);
])
.with_mounted_directory(".", workdir.id().await?);
let exit_code = rust_cacher.exit_code().await?;
if exit_code != 0 {
eyre::bail!("could not build cacher");
}
let rust_builder = rust_base
let nodejs_cacher = client.cache_volume("node");
// something
let rust_pre_builder = rust_cacher
.with_exec(vec!["mkdir", "-p", "node"])
.with_mounted_cache("node", nodejs_cacher.id().await?)
.with_exec(vec![
"curl",
"-sL",
"https://deb.nodesource.com/setup_12.x",
"-o",
"/node_12.txt",
"node/node_12.txt",
])
.with_exec(vec!["chmod", "+x", "/node_12.txt"])
.with_exec(vec!["bash", "-c", "/node_12.txt"])
.with_exec(vec!["chmod", "+x", "node/node_12.txt"])
.with_exec(vec!["bash", "-c", "node/node_12.txt"])
.with_exec(vec!["apt-get", "update"])
.with_exec(vec!["apt-get", "install", "nodejs"])
.with_mounted_directory(".", workdir.id().await?)
.with_directory(
"/app/target",
rust_cacher.directory("/app/target").id().await?,
)
.with_directory(
"/usr/local/cargo",
rust_cacher.directory("/usr/local/cargo").id().await?,
)
.with_exec(vec!["rustup", "target", "add", "wasm32-unknown-unknown"])
.with_exec(vec!["npm", "install", "-g", "sass"])
.with_exec(vec!["npm", "install", "-g", "sass"]);
let exit_code = rust_pre_builder.exit_code().await?;
if exit_code != 0 {
eyre::bail!("could not build rust_pre_builder");
}
let rust_builder = rust_pre_builder
.with_env_variable("LEPTOS_BROWSERQUERY", "defaults")
.with_exec(vec!["cargo", "leptos", "build", "--release"]);
@@ -131,16 +148,49 @@ async fn main() -> eyre::Result<()> {
let tag = chrono::Utc::now().timestamp();
let prod_image = "gcr.io/distroless/cc-debian11";
let prod_image = "debian:bullseye";
let prod = client
.container()
.from(prod_image)
.with_exec(vec!["apt", "update"])
.with_exec(vec!["apt", "install", "-y", "zlib1g", "git"])
.with_workdir("/app")
.with_directory("/app", rust_builder.directory("/app/target").id().await?)
.with_env_variable("LEPTOS_SITE_ADDRESS", "0.0.0.0:3000")
.with_entrypoint(vec!["/app/server/release/ssr_mode_axum"]);
.with_file(
"/app/ssr_modes",
rust_builder
.file("/app/target/server/release/ssr_modes")
.id()
.await?,
)
.with_directory(
"/app/site",
rust_builder.directory("/app/target/site").id().await?,
)
.with_env_variable("LEPTOS_OUTPUT_NAME", "ssr_modes")
.with_env_variable("LEPTOS_SITE_ROOT", "site")
.with_env_variable("LEPTOS_SITE_PKG_DIR", "pkg")
.with_env_variable("LEPTOS_SITE_ADDR", "0.0.0.0:3000")
.with_env_variable("LEPTOS_RELOAD_PORT", "3001")
.with_entrypoint(vec!["/app/ssr_modes"]);
prod.publish(format!("docker.io/kasperhermansen/bitebuds:{tag}"))
let image_tag = format!("docker.io/kasperhermansen/bitebuds:{tag}");
prod.publish(&image_tag).await?;
let update_deployment = client
.container()
.from("docker.io/kasperhermansen/update-deployment:1680548342")
.with_env_variable("GIT_USERNAME", "kjuulh")
.with_env_variable("GIT_PASSWORD", std::env::var("GIT_PASSWORD").unwrap())
.with_exec(vec![
"update-deployment",
"--repo",
"https://git.front.kjuulh.io/kjuulh/bitebuds-deployment.git",
"--service",
"bitebuds",
"--image",
&image_tag,
])
.exit_code()
.await?;
Ok(())

View File

@@ -1,3 +1,5 @@
use std::path::PathBuf;
use domain::{Event, Image};
use inquire::validator::ValueRequiredValidator;
use regex::Regex;
@@ -9,7 +11,12 @@ async fn main() -> eyre::Result<()> {
color_eyre::install()?;
let cli = clap::Command::new("biteme")
.subcommand(clap::Command::new("generate").subcommand(clap::Command::new("article")));
.subcommand_required(true)
.subcommand(
clap::Command::new("generate")
.subcommand_required(true)
.subcommand(clap::Command::new("article")),
);
let args = std::env::args();
@@ -89,7 +96,10 @@ async fn generate_article() -> eyre::Result<()> {
description.unwrap_or("".into())
);
tokio::fs::write(format!("articles/events/{}.md", slug), contents).await?;
let mut vault_path = PathBuf::from(std::env::var("BITEME_ROOT").unwrap());
vault_path.push(format!("areas/food/events/{}.md", slug));
tokio::fs::write(vault_path, contents).await?;
Ok(())
}

View File

@@ -80,6 +80,7 @@ struct InnerEventStore {
url: Option<String>,
pub path: PathBuf,
events: Arc<tokio::sync::RwLock<Vec<Event>>>,
url_path: Option<String>,
}
#[derive(Clone)]
@@ -92,9 +93,13 @@ impl EventStore {
let article_repo_url = std::env::var("BITE_ARTICLE_REPO_URL")
.map(|a| (a != "").then(|| a))
.unwrap_or(None);
let article_repo_path = std::env::var("BITE_ARTICLE_REPO_PATH")
.map(|a| (a != "").then(|| a))
.unwrap_or(None);
Self {
inner: Arc::new(InnerEventStore {
url: article_repo_url,
url_path: article_repo_path,
path,
events: Default::default(),
}),
@@ -127,7 +132,7 @@ impl EventStore {
async move {
tracing::info!("updating articles");
let mut event_path = req.git.path.clone();
event_path.push("articles/events");
event_path.push(inner.url_path.as_ref().unwrap());
tracing::debug!(
path = event_path.display().to_string(),
@@ -199,6 +204,7 @@ impl Default for EventStore {
url: Default::default(),
path: PathBuf::from("articles"),
events: Default::default(),
url_path: Some("articles/events".into()),
}),
}
}

3
renovate.json Normal file
View File

@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}

View File

@@ -20,7 +20,7 @@ cfg_if! {
.await
.map_err(|e| ServerFnError::ServerError(e.to_string()))?
.iter()
.filter(|d| d.time.gt(&chrono::Utc::now().date_naive()))
.filter(|d| d.time.ge(&chrono::Utc::now().date_naive()))
.map(|data| data.clone().into())
.collect();

View File

@@ -13,6 +13,8 @@ pub fn App(cx: Scope) -> impl IntoView {
<Stylesheet id="leptos" href="/pkg/ssr_modes.css" />
<Title text="Bitebuds" />
<script defer="true" data-domain="bitebuds.front.kjuulh.io" src="https://plausible.front.kjuulh.io/js/script.js"/>
<Router>
<div class="app grid lg:grid-cols-[25%,50%,25%] sm:grid-cols-[10%,80%,10%] grid-cols-[5%,90%,5%]">
<main class="main col-start-2">

View File

@@ -4,21 +4,22 @@ async fn main() {
use axum::{extract::Extension, routing::post, Router};
use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use ssr_modes_axum::app::*;
use ssr_modes_axum::fallback::file_and_error_handler;
use ssr_modes::app::*;
use ssr_modes::fallback::file_and_error_handler;
use std::sync::Arc;
use tracing::metadata::LevelFilter;
use tracing_subscriber::EnvFilter;
std::env::set_var(
"BITE_ARTICLE_REPO_URL",
"git@git.front.kjuulh.io:kjuulh/articles.git",
"git@git.front.kjuulh.io:kjuulh/obsidian.git",
);
std::env::set_var("BITE_ARTICLE_REPO_PATH", "areas/food/events");
tracing_subscriber::fmt()
.with_max_level(LevelFilter::TRACE)
.with_env_filter(EnvFilter::from_default_env())
.init();
ssr_modes_axum::api::events::boostrap().await.unwrap();
ssr_modes::api::events::boostrap().await.unwrap();
let conf = get_configuration(None).await.unwrap();
let addr = conf.leptos_options.site_addr;
@@ -26,7 +27,7 @@ async fn main() {
// Generate the list of routes in your Leptos App
let routes = generate_route_list(|cx| view! { cx, <App/> }).await;
ssr_modes_axum::api::register();
ssr_modes::api::register();
let app = Router::new()
.route("/api/*fn_name", post(leptos_axum::handle_server_fns))

View File

@@ -655,22 +655,6 @@ video {
flex-grow: 1;
}
@keyframes bounce {
0%, 100% {
transform: translateY(-25%);
animation-timing-function: cubic-bezier(0.8,0,1,1);
}
50% {
transform: none;
animation-timing-function: cubic-bezier(0,0,0.2,1);
}
}
.animate-bounce {
animation: bounce 1s infinite;
}
@keyframes pulse {
50% {
opacity: .5;
@@ -769,20 +753,6 @@ video {
border-top-right-radius: 1rem;
}
.border {
border-width: 1px;
}
.border-gray-400 {
--tw-border-opacity: 1;
border-color: rgb(156 163 175 / var(--tw-border-opacity));
}
.border-gray-300 {
--tw-border-opacity: 1;
border-color: rgb(209 213 219 / var(--tw-border-opacity));
}
.bg-gray-200 {
--tw-bg-opacity: 1;
background-color: rgb(229 231 235 / var(--tw-bg-opacity));