Skip to content

Commit

Permalink
chore: add docker-compose.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Oct 29, 2024
1 parent 9d304d1 commit 7b08a03
Show file tree
Hide file tree
Showing 456 changed files with 5,046 additions and 133 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*

!Cargo.lock
!Cargo.toml
!sdks/full/rust/Cargo.toml
!sdks/full/rust/src
!packages
!resources/legacy/proto

sdks/runtime
svc/**/*.md

13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resolver = "2"
# Find all packages with: find . -name Cargo.toml | grep -v "sdks/runtime" | grep -v "sdks/full/rust-cli" | grep -v "infra/" | sed -E 's|^./(.*)Cargo\.toml$|"\1",|'
members = [
"sdks/full/rust/",
"sdks/full/rust-cli/",
"packages/cli/",
"packages/common/operation/core/",
"packages/common/operation/macros/",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/cloud/src/route/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub async fn build_bootstrap_data(
None
},
origins: Box::new(models::CloudBootstrapOrigins {
hub: config.server()?.rivet.hub.public_origin.to_string(),
hub: config.server()?.rivet.hub.public_origin().to_string(),
}),
captcha: Box::new(models::CloudBootstrapCaptcha {
turnstile: server_config
Expand Down
3 changes: 2 additions & 1 deletion packages/api/internal-monolith/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> G
api_helper::start(
config.clone(),
pools,
config.server()?.rivet.api_internal.port,
config.server()?.rivet.api_internal.host(),
config.server()?.rivet.api_internal.port(),
route::handle,
)
.await;
Expand Down
3 changes: 2 additions & 1 deletion packages/api/monolith/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> G
api_helper::start(
config.clone(),
pools,
config.server()?.rivet.api_internal.port,
config.server()?.rivet.api.host(),
config.server()?.rivet.api.port(),
route::handle,
)
.await;
Expand Down
14 changes: 13 additions & 1 deletion packages/cli/src/commands/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::run_config::RunConfig;

#[derive(Parser)]
pub struct Opts {
#[arg(long)]
skip_provision: bool,
#[arg(long, value_enum)]
services: Vec<ServiceKind>,
}
Expand Down Expand Up @@ -39,6 +41,16 @@ impl Opts {
config: rivet_config::Config,
run_config: &RunConfig,
) -> Result<()> {
// Provision services before starting server
if !self.skip_provision {
tracing::info!("provisioning s3");
s3_util::provision(config.clone(), &run_config.s3_buckets).await?;

tracing::info!("migrating database");
rivet_migrate::up(config.clone(), &run_config.sql_services).await?;
}

// Select services t orun
let services = if self.services.is_empty() {
// Run all services
run_config.services.clone()
Expand All @@ -58,8 +70,8 @@ impl Opts {
.collect::<Vec<_>>()
};

// Start server
let pools = rivet_pools::Pools::new(config.clone()).await?;

rivet_server::start(config, pools, services).await?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub async fn redis_shell(config: rivet_config::Config, shell_ctx: ShellContext<'
cmd.arg("--user").arg(username);
}
if let Some(password) = &redis_config.password {
cmd.arg("--password").arg(password.read());
cmd.arg("--pass").arg(password.read());
}

let ca_path = format!("/usr/local/share/ca-certificates/redis-{svc}-ca.crt");
Expand Down
4 changes: 2 additions & 2 deletions packages/common/api-helper/build/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn handle_rejection(
.expect("missing server")
.rivet
.api
.verbose_errors
.verbose_errors()
{
err_code!(ERROR, error = err.to_string())
} else {
Expand All @@ -59,7 +59,7 @@ pub fn handle_rejection(
.expect("missing server")
.rivet
.api
.verbose_errors
.verbose_errors()
{
err_code!(ERROR, error = err.to_string())
} else {
Expand Down
8 changes: 1 addition & 7 deletions packages/common/api-helper/build/src/macro_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,10 @@ pub struct __RouterConfig {
#[doc(hidden)]
impl __RouterConfig {
pub fn new(config: &rivet_config::Config, uri: &hyper::Uri) -> GlobalResult<Self> {
let origin = config
.server()?
.rivet
.api
.public_origin
.to_string();

// NOTE: We do not use `Url::join` because it normalizes paths
// This url doesn't actually represent the url of the request, it's just put here so that the
// URI can be parsed by url::Url::parse
let origin = config.server()?.rivet.api.public_origin().to_string();
let url = format!("{}{}", origin.trim_end_matches('/'), uri);
let route = url::Url::parse(url.as_str())?;

Expand Down
12 changes: 9 additions & 3 deletions packages/common/api-helper/build/src/start.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use std::{convert::Infallible, future::Future, net::SocketAddr, time::Instant};
use std::{
convert::Infallible,
future::Future,
net::{IpAddr, SocketAddr},
time::Instant,
};

use hyper::{
body::HttpBody,
Expand All @@ -13,6 +18,7 @@ use uuid::Uuid;
pub async fn start<T: 'static, Fut>(
config: rivet_config::Config,
pools: rivet_pools::Pools,
host: IpAddr,
port: u16,
handle: T,
) where
Expand Down Expand Up @@ -127,10 +133,10 @@ pub async fn start<T: 'static, Fut>(
async move { Ok::<_, Infallible>(service) }
});

let addr = SocketAddr::from(([0, 0, 0, 0], port));
let addr = SocketAddr::from((host, port));
let server = Server::bind(&addr).serve(make_service);

tracing::info!(?port, "server listening");
tracing::info!(?host, ?port, "server listening");
if let Err(e) = server.await {
eprintln!("server error: {}", e);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/api-helper/build/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rivet_claims::ClaimsDecode;
/// Origins that the hub may be requesting from.
pub fn hub_origin_regex(config: &rivet_config::Config) -> Regex {
// TODO: Make this lazy static to prevent reparsing regex for every request
let regex_str = &config.server().unwrap().rivet.hub.public_origin_regex;
let regex_str = &config.server().unwrap().rivet.hub.public_origin_regex();
let regex = Regex::new(&regex_str).expect("failed to build hub origin regex");
regex
}
Expand Down
6 changes: 4 additions & 2 deletions packages/common/config/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ impl Default for S3 {
region: "us-east-1".into(),
endpoint_internal: Url::parse("http://127.0.0.1:9000").unwrap(),
endpoint_external: Url::parse("http://127.0.0.1:9000").unwrap(),
access_key_id: Secret::new("minioadmin".into()),
secret_access_key: Secret::new("minioadmin".into()),
access_key_id: Secret::new("root".into()),
secret_access_key: Secret::new("root".into()),
}
}
}
Expand Down Expand Up @@ -442,7 +442,9 @@ impl Default for Nats {
pub struct ClickHouse {
pub url: Url,
pub username: String,
#[serde(default)]
pub password: Option<Secret<String>>,
#[serde(default)]
pub provision_users: HashMap<String, ClickHouseUser>,
}

Expand Down
Loading

0 comments on commit 7b08a03

Please sign in to comment.