Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: doseiai/dosei
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.0.21
Choose a base ref
...
head repository: doseiai/dosei
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 13 commits
  • 38 files changed
  • 2 contributors

Commits on Mar 21, 2024

  1. fix(docs): update actions

    Alw3ys committed Mar 21, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    65f90da View commit details

Commits on Mar 22, 2024

  1. feat: remove export command

    Alw3ys committed Mar 22, 2024
    Copy the full SHA
    63695f5 View commit details

Commits on Mar 24, 2024

  1. feat: spin up console

    Alw3ys committed Mar 24, 2024
    Copy the full SHA
    d5ff973 View commit details

Commits on Apr 4, 2024

  1. fix: cron-jobs link in readme

    williamhogman authored Apr 4, 2024
    Copy the full SHA
    3042c4f View commit details
  2. Update README.md

    Alw3ys authored Apr 4, 2024
    Copy the full SHA
    5542dec View commit details
  3. feat: deployments

    Alw3ys committed Apr 4, 2024
    Copy the full SHA
    1d049ac View commit details

Commits on Apr 5, 2024

  1. docker run with postgres

    Alw3ys committed Apr 5, 2024
    Copy the full SHA
    0e6029b View commit details
  2. chore(release): 0.0.22

    Alw3ys committed Apr 5, 2024
    Copy the full SHA
    c967b11 View commit details
  3. lint

    Alw3ys committed Apr 5, 2024
    Copy the full SHA
    7249328 View commit details
  4. feat: add cluster info

    Alw3ys committed Apr 5, 2024
    Copy the full SHA
    4611218 View commit details

Commits on Apr 10, 2024

  1. feat: generate random JWT_SECRET when not provided

    Alw3ys committed Apr 10, 2024
    Copy the full SHA
    4a725c5 View commit details
  2. feat: 0.0.23

    Alw3ys committed Apr 10, 2024
    Copy the full SHA
    0a0e7a3 View commit details
  3. chore: bump cargo to 1.77.2

    Alw3ys committed Apr 10, 2024
    Copy the full SHA
    808bdce View commit details
Showing with 692 additions and 220 deletions.
  1. +11 −1 .dockerignore
  2. +0 −15 .env.example
  3. +23 −5 Cargo.lock
  4. +1 −1 Cargo.toml
  5. +15 −1 Dockerfile
  6. +0 −9 Makefile
  7. +5 −3 README.md
  8. +1 −0 cli/Cargo.toml
  9. +1 −1 cli/README.md
  10. +0 −40 cli/src/command/export.rs
  11. +8 −0 cli/src/command/info.rs
  12. +2 −1 cli/src/command/mod.rs
  13. +10 −6 cli/src/command/run.rs
  14. +78 −0 cli/src/command/service.rs
  15. +9 −4 cli/src/main.rs
  16. +0 −16 docker-compose.base.yml
  17. +0 −29 docker-compose.test.yml
  18. +11 −23 docker-compose.yml
  19. +3 −2 ...3d277afc1f4dc.json → query-4fdef9e8f4fcd0ebcabbad226255332640bc0e5bcade3e8126a15d18f4a5cd5e.json}
  20. +2 −2 ...dd68f40264257.json → query-69f106e5ed65f632b5bdaa3e3ffb306d5e82ce1befcac813057cbe05e9422a0a.json}
  21. +23 −0 doseid/.sqlx/query-7fadc5392569c42d56abae527d2b605bd5ef8fdb6b099cccf95e29da0169efed.json
  22. +96 −0 doseid/.sqlx/query-9ba30b8e74e13f0e0dbccadc5394a422210a91a7674ceab18be81eb9991e14e3.json
  23. +69 −0 doseid/.sqlx/query-f376e1e4ccc715daa24681a0b89ae02d73cfce11bc1841b0955e10b6daf2a4a5.json
  24. +1 −0 doseid/Cargo.toml
  25. +1 −1 doseid/resources/doseid.toml
  26. +132 −0 doseid/resources/pg_hba.conf
  27. +16 −1 doseid/src/config.rs
  28. +18 −0 doseid/src/deployment/app.rs
  29. +1 −1 doseid/src/server/app.rs
  30. +1 −1 doseid/src/server/deployment/mod.rs
  31. +25 −2 doseid/src/server/deployment/route.rs
  32. +1 −0 doseid/src/server/deployment/schema.rs
  33. +11 −0 doseid/src/server/mod.rs
  34. +48 −27 doseid/src/server/project/mod.rs
  35. +56 −0 doseid/src/server/project/route.rs
  36. +12 −0 entrypoint.sh
  37. +1 −1 rust-toolchain.toml
  38. +0 −27 script/configure-compose.sh
12 changes: 11 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
data/
target/
.env
.env.example
.env*
.vscode/
*.DS_Store

# Dosei application things
.dosei/
dosei_config.*

__pycache__/

.idea/
15 changes: 0 additions & 15 deletions .env.example

This file was deleted.

28 changes: 23 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ members = ["proto", "doseid", "proxy", "util", 'cli']
resolver = "2"

[workspace.package]
version = "0.0.21"
version = "0.0.23"
license = "Apache-2.0"
repository = "https://github.com/doseiai/dosei"
authors = [
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -21,13 +21,26 @@ RUN cargo build --release

FROM debian:12-slim AS runtime

## Postgres
RUN apt-get update && apt-get install -y wget gnupg lsb-release

RUN sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt-get update && apt-get -y install postgresql

COPY doseid/resources/pg_hba.conf /etc/postgresql/16/main/
VOLUME /var/lib/postgresql/data

LABEL org.opencontainers.image.title="Dosei"
LABEL org.opencontainers.image.description="Official Dosei image"
LABEL org.opencontainers.image.url="https://dosei.ai"
LABEL org.opencontainers.image.documentation="https://dosei.ai/docs"
LABEL org.opencontainers.image.source="https://github.com/doseiai/dosei"
LABEL org.opencontainers.image.vendor="Dosei"

# Dosei
RUN apt-get update && apt-get install python3.11-dev -y

ARG RELEASE_PATH=/dosei/target/release
@@ -37,4 +50,5 @@ COPY --from=builder $RELEASE_PATH/doseid $TAGET_PATH
COPY --from=builder $RELEASE_PATH/dosei $TAGET_PATH
COPY --from=builder $RELEASE_PATH/proxy $TAGET_PATH

ENTRYPOINT ["/usr/local/bin/doseid"]
COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT ["entrypoint.sh"]
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -4,15 +4,6 @@ build:
dev:
cargo run --bin doseid

dev-compose:
docker compose -f docker-compose.base.yml up --build

test-compose:
docker compose -f docker-compose.test.yml up --build

configure-compose:
./script/configure-compose.sh

lint:
cargo fmt
cargo clippy --release --all-targets --all-features -- -D clippy::all
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ That's where Dosei comes in! Self-hosted, IaC and local development first experi
- **Fast**: 🦀 [Rust](https://www.rust-lang.org/) is blazingly fast and Dosei is built on top of it!
- **Language agnostic IaC**: We officially support SDKS in [Python](https://github.com/doseiai/python-sdk) and [JavaScript](https://github.com/doseiai/javascript-sdk)
- **Local first**: Build, test and run your infrastructure locally!
- [Cron Jobs](https://docs.dosei.ai/cron-jobs): Locally testable, versioned and scalable Cron Jobs!
- [Cron Jobs](https://dosei.ai/docs/cron-jobs): Locally testable, versioned and scalable Cron Jobs!

At it's core Dosei is really an infrastructure runtime for Developers

@@ -43,9 +43,11 @@ This is what you need to run Dosei.

- Docker

### Install Dosei with Docker Compose
### Run Dosei with Docker

Follow [our installation guide](https://docs.dosei.ai/getting-started) to set up Dosei using Docker Compose.
```
docker run -v /var/run/docker.sock:/var/run/docker.sock doseiai/dosei
```

## License

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -25,3 +25,4 @@ ignore = { version = "0.4.22" }
regex = "1.10.3"
git2 = { version = "0.18.1",features = ["vendored-openssl"] }
tempfile = "3.10.1"
chrono = { version = "0.4.31", features = ["serde"] }
2 changes: 1 addition & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@
## Learn more

* The best place to get started is following our getting started guide on the [Dosei CLI Documentation](https://dosei.ai/docs/cli).
* [Official Github Action](https://github.com/doseiai/setup-dctl)
* [Official Github Action](https://github.com/doseiai/setup-dosei)
40 changes: 0 additions & 40 deletions cli/src/command/export.rs

This file was deleted.

8 changes: 8 additions & 0 deletions cli/src/command/info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::cluster::get_cluster_info;
use crate::config::Config;

pub fn cluster_info(config: &'static Config) {
let cluster_info = get_cluster_info(config).unwrap();
let json_info = serde_json::to_string(&cluster_info).unwrap();
println!("{}", json_info);
}
3 changes: 2 additions & 1 deletion cli/src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -4,11 +4,12 @@ use std::path::Path;
pub(crate) mod certificate;
pub(crate) mod deploy;
pub(crate) mod env;
pub(crate) mod export;
pub(crate) mod info;
pub(crate) mod login;
pub(crate) mod logout;
pub(crate) mod new;
pub(crate) mod run;
pub(crate) mod service;
pub(crate) mod session;
pub(crate) mod token;

16 changes: 10 additions & 6 deletions cli/src/command/run.rs
Original file line number Diff line number Diff line change
@@ -4,16 +4,19 @@ use std::path::Path;
use std::process::Stdio;

pub fn sub_command() -> Command {
Command::new("run")
.about("Execute a Dosei App")
.arg(Arg::new("function").index(1).required(false))
Command::new("run").about("Execute a Dosei App").arg(
Arg::new("function")
.help("The function to run; Eg. module.sub_module:function_name")
.index(1)
.required(false),
)
}

pub fn run(arg_matches: &ArgMatches) {
let function = arg_matches.get_one::<String>("function");
let path = Path::new(".");
if let Ok(extension) = find_and_print_dosei_config_extension(path) {
match extension.as_str() {
match find_and_print_dosei_config_extension(path) {
Ok(extension) => match extension.as_str() {
"py" => {
let arg = match function {
Some(command) => format!("from dosei_sdk import main\nmain.run(\"{}\")", command),
@@ -33,6 +36,7 @@ pub fn run(arg_matches: &ArgMatches) {
todo!()
}
_ => unreachable!(),
}
},
Err(e) => eprintln!("{}", e),
}
}
78 changes: 78 additions & 0 deletions cli/src/command/service.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
use crate::config::Config;
use chrono::{DateTime, Utc};
use clap::Command;
use serde::{Deserialize, Serialize};

pub fn sub_command() -> Command {
Command::new("service")
.about("Services commands")
.subcommand_required(true)
.subcommand(Command::new("list").about("List Services"))
}

pub fn list_services(config: &'static Config) {
let response = config
.cluster_api_client()
.expect("Client connection failed")
.get(format!("{}/projects", config.api_base_url))
.bearer_auth(config.bearer_token())
.send()
.unwrap();
if response.status().is_success() {
let services = response.json::<Vec<Service>>().unwrap();

let headers = vec!["Name", "Last updated"];
let mut rows = vec![];
for service in services {
rows.push(vec![service.name, format_time_ago(service.updated_at)]);
}
print_table(headers, rows);
}
}

fn print_table(headers: Vec<&str>, rows: Vec<Vec<String>>) {
let num_columns = headers.len();
let mut column_widths = vec![0; num_columns];
for (i, header) in headers.iter().enumerate() {
column_widths[i] = header.len();
}
for row in &rows {
for (i, item) in row.iter().enumerate() {
column_widths[i] = column_widths[i].max(item.len());
}
}
for (i, header) in headers.iter().enumerate() {
print!("{:<width$} ", header, width = column_widths[i]);
}
println!();

for row in rows {
for (i, item) in row.iter().enumerate() {
print!("{:<width$} ", item, width = column_widths[i]);
}
println!();
}
}

fn format_time_ago(from_datetime: DateTime<Utc>) -> String {
let now = Utc::now();
let duration = now.signed_duration_since(from_datetime);

if duration.num_days() >= 1 {
format!("{}d", duration.num_days())
} else if duration.num_hours() >= 1 {
format!("{}h", duration.num_hours())
} else if duration.num_minutes() >= 1 {
format!("{}m", duration.num_minutes())
} else if duration.num_seconds() >= 1 {
format!("{}s", duration.num_seconds())
} else {
"just now".to_string()
}
}

#[derive(Debug, Serialize, Deserialize)]
struct Service {
name: String,
updated_at: DateTime<Utc>,
}
Loading