Compare commits
58 Commits
Author | SHA1 | Date | |
---|---|---|---|
15dc37932c | |||
e69bbfd490 | |||
1a305f0c1a | |||
46d0899d9a | |||
d5acdfd92f | |||
7ca49e4ac2 | |||
d5df0ccfd7 | |||
f64d5fe18d | |||
d81bb038eb | |||
db97bded51 | |||
1112ae5382 | |||
53650f5faa | |||
7c6c325a52 | |||
74d462d5b9 | |||
307a202eb9 | |||
7c66fcdcab | |||
4e2e6a2931 | |||
301d59ea63 | |||
ceba22989a | |||
5df67817bb | |||
b22e680256 | |||
81d18ad3ce | |||
450e621263 | |||
20eaee5994 | |||
21169cfa30 | |||
ba559f2703 | |||
e551cc8bd8 | |||
584dc9276f | |||
0569468d3a | |||
593cdd1986 | |||
9741e07ad8 | |||
9ff87e21bf | |||
adc03cfa57 | |||
2eeb007611 | |||
6c26a4d673 | |||
2180ab030c | |||
09fc4af290 | |||
a2a2643055 | |||
5e07ce1ca9 | |||
05789ab358 | |||
e24fd65edc | |||
2d729b38f9 | |||
6c14466a01 | |||
5cf3c5ee3a | |||
72bcd46238 | |||
29c27edc2f | |||
47db2cea41 | |||
d77859a35e | |||
6fc96b185a | |||
d66f259469 | |||
e8f23d2322 | |||
94ae4d53d3 | |||
b2f704856a | |||
8d7c3cfd80 | |||
54725c37b3 | |||
fe33018847 | |||
77ec548760 | |||
0bc17eb232 |
90
.drone.yml
90
.drone.yml
@ -1,88 +1,2 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
type: docker
|
||||
|
||||
steps:
|
||||
- name: load_secret
|
||||
image: debian:buster-slim
|
||||
volumes:
|
||||
- name: ssh
|
||||
path: /root/.ssh/
|
||||
environment:
|
||||
SSH_KEY:
|
||||
from_secret: gitea_id_ed25519
|
||||
commands:
|
||||
- mkdir -p $HOME/.ssh/
|
||||
- echo "$SSH_KEY" | base64 -d > $HOME/.ssh/id_ed25519
|
||||
|
||||
- name: build
|
||||
image: kasperhermansen/cuddle:latest
|
||||
pull: always
|
||||
volumes:
|
||||
- name: ssh
|
||||
path: /root/.ssh/
|
||||
- name: dockersock
|
||||
path: /var/run
|
||||
commands:
|
||||
- apk add bash git
|
||||
- git remote set-url origin $DRONE_GIT_SSH_URL
|
||||
- cuddle_cli x setup_ssh
|
||||
- cuddle_cli x start_deployment
|
||||
- cuddle_cli x render_templates
|
||||
- cuddle_cli x render_cibus_templates
|
||||
- cuddle_cli x build_release
|
||||
- cuddle_cli x push_release
|
||||
- cuddle_cli x deploy_release
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
DOCKER_USERNAME:
|
||||
from_secret: docker_username
|
||||
DOCKER_PASSWORD:
|
||||
from_secret: docker_password
|
||||
SSH_KEY:
|
||||
from_secret: gitea_id_ed25519
|
||||
|
||||
- name: push_tags
|
||||
image: kasperhermansen/drone-semantic-release:latest
|
||||
pull: always
|
||||
volumes:
|
||||
- name: ssh
|
||||
path: /root/.ssh/
|
||||
- name: dockersock
|
||||
path: /var/run
|
||||
commands:
|
||||
- semantic-release --no-ci
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
SSH_KEY:
|
||||
from_secret: gitea_id_ed25519
|
||||
depends_on:
|
||||
- build
|
||||
|
||||
- name: send telegram notification
|
||||
image: appleboy/drone-telegram
|
||||
settings:
|
||||
token:
|
||||
from_secret: telegram_token
|
||||
to: 2129601481
|
||||
format: markdown
|
||||
depends_on:
|
||||
- build
|
||||
- push_tags
|
||||
when:
|
||||
status: [failure, success]
|
||||
|
||||
services:
|
||||
- name: docker
|
||||
image: docker:dind
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run
|
||||
volumes:
|
||||
- name: ssh
|
||||
temp: {}
|
||||
- name: dockersock
|
||||
temp: {}
|
||||
|
||||
|
||||
kind: template
|
||||
load: cuddle-rust-service-plan.yaml
|
||||
|
2002
Cargo.lock
generated
2002
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"cibus_bin"
|
||||
"crates/*"
|
||||
]
|
||||
resolver = "2"
|
||||
|
@ -1,18 +0,0 @@
|
||||
[package]
|
||||
name = "cibus_bin"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-graphql = "4.0.6"
|
||||
axum = "0.5.13"
|
||||
tokio = {version="1.20.1", features=["full"]}
|
||||
uuid = {version="1.1.2", features=["v4", "fast-rng"]}
|
||||
sqlx = { version = "0.6", features = [ "runtime-tokio-rustls", "postgres", "migrate"] }
|
||||
anyhow = "1.0.60"
|
||||
dotenv = "0.15.0"
|
||||
tracing = "0.1.36"
|
||||
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
|
||||
tower-http = { version = "0.3.4", features = ["full"] }
|
18
crates/cibus_backend/Cargo.toml
Normal file
18
crates/cibus_backend/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "cibus-backend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-graphql = "7.0.5"
|
||||
axum = "0.8.0"
|
||||
tokio = {version="1.37.0", features=["full"]}
|
||||
uuid = {version="1.8.0", features=["v4", "fast-rng"]}
|
||||
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "postgres", "migrate"] }
|
||||
anyhow = "1.0.86"
|
||||
dotenv = "0.15.0"
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
tower-http = { version = "0.6.0", features = ["full"] }
|
@ -16,6 +16,7 @@ use async_graphql::{
|
||||
};
|
||||
use graphql::CibusSchema;
|
||||
use sqlx::PgPool;
|
||||
use tokio::net::TcpListener;
|
||||
use tower_http::{cors::CorsLayer, trace::TraceLayer};
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
@ -39,7 +40,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::EnvFilter::new(
|
||||
std::env::var("RUST_LOG").unwrap_or_else(|_| {
|
||||
"cibus_bin=debug,tower_http=debug,axum_extra=debug,hyper=info,mio=info".into()
|
||||
"cibus-backend=debug,tower_http=debug,axum_extra=debug,hyper=info,mio=info".into()
|
||||
}),
|
||||
))
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
@ -77,8 +78,9 @@ async fn main() -> anyhow::Result<()> {
|
||||
);
|
||||
|
||||
tracing::info!("Starting webserver");
|
||||
axum::Server::bind(&"0.0.0.0:3001".parse().unwrap())
|
||||
.serve(app.into_make_service())
|
||||
|
||||
let listener = TcpListener::bind("0.0.0.0:3001").await?;
|
||||
axum::serve(listener, app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
|
17
cuddle.yaml
17
cuddle.yaml
@ -1,10 +1,23 @@
|
||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||
|
||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-plan.git"
|
||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-service-plan.git"
|
||||
|
||||
vars:
|
||||
service: "cibus-backend"
|
||||
deployments: "git@git.front.kjuulh.io:cibus/deployments.git"
|
||||
registry: kasperhermansen
|
||||
|
||||
clusters:
|
||||
clank-prod:
|
||||
replicas: "3"
|
||||
namespace: prod
|
||||
|
||||
|
||||
deployment:
|
||||
registry: git@git.front.kjuulh.io:kjuulh/clank-clusters
|
||||
env:
|
||||
prod:
|
||||
clusters:
|
||||
- clank-prod
|
||||
|
||||
scripts:
|
||||
render_cibus_templates:
|
||||
|
120
local.sh
120
local.sh
@ -1,120 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
name="cibus_postgres"
|
||||
image="postgres"
|
||||
version="latest"
|
||||
ports="5432:5432"
|
||||
db_name="cibus"
|
||||
|
||||
command=$1
|
||||
arg_first=$2
|
||||
already_running=$(docker ps | grep "$name")
|
||||
|
||||
bin_path="./cibus_bin"
|
||||
env_path="$bin_path/.env"
|
||||
|
||||
echo "local environment : (command=$command)"
|
||||
|
||||
function log_out {
|
||||
green="\033[0;32m"
|
||||
no_color="\033[0m"
|
||||
awk \
|
||||
-v green=$green \
|
||||
-v nocolor=$no_color \
|
||||
-v name=$name \
|
||||
'{ printf "\n%s%s: %s%s", green, name, nocolor, $0; fflush(); }'
|
||||
}
|
||||
|
||||
function handle_commands {
|
||||
if [[ $command == 'up' ]]
|
||||
then
|
||||
echo "starting local env"
|
||||
echo
|
||||
if [[ -n $already_running ]]
|
||||
then
|
||||
echo "docker image already running"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
docker pull postgres:latest
|
||||
docker run \
|
||||
-p "$ports" \
|
||||
-d \
|
||||
--rm \
|
||||
--env-file "$env_path" \
|
||||
--name "$name" \
|
||||
"$image:$version"
|
||||
echo
|
||||
echo "started local env"
|
||||
elif [[ $command == 'down' ]]
|
||||
then
|
||||
echo "stopping local env"
|
||||
echo
|
||||
if [[ -n $already_running ]]
|
||||
then
|
||||
docker stop "$name" > /dev/null
|
||||
echo "stopped and removed: $name"
|
||||
else
|
||||
echo "container: $name is not running"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "stopped local env"
|
||||
elif [[ $command == 'logs' ]]
|
||||
then
|
||||
|
||||
docker logs "$name" | log_out
|
||||
|
||||
elif [[ $command == 'connect_db' ]]
|
||||
then
|
||||
echo "connecting to db"
|
||||
echo
|
||||
if [[ -z $already_running ]]
|
||||
then
|
||||
echo "container not running cannot connect to db"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker exec -it "$name" psql --user "$db_name" --db "$db_name"
|
||||
|
||||
echo
|
||||
echo "exited db"
|
||||
|
||||
elif [[ $command == 'print_migration' ]]
|
||||
then
|
||||
echo "printing migrations"
|
||||
echo
|
||||
if [[ -z $already_running ]]
|
||||
then
|
||||
echo "container not running cannot check migrations"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "database"
|
||||
docker exec -it "$name" psql --user "$db_name" --db "$db_name" -c "select version, description, success from _sqlx_migrations;"
|
||||
|
||||
echo "sqlx"
|
||||
migration_path="$bin_path/db"
|
||||
(cd "$migration_path" && sqlx migrate info)
|
||||
|
||||
echo
|
||||
echo "exited db"
|
||||
|
||||
elif [[ $command == 'add_migration' ]]
|
||||
then
|
||||
echo "adding migration"
|
||||
echo
|
||||
migration_path="$bin_path/db"
|
||||
(cd "$migration_path" && sqlx migrate add "$arg_first")
|
||||
echo
|
||||
echo "added migration"
|
||||
else
|
||||
echo "please provide a valid command (up / down)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
handle_commands
|
||||
|
||||
exit 0
|
3
renovate.json
Normal file
3
renovate.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||
}
|
@ -2,4 +2,4 @@
|
||||
|
||||
set -e
|
||||
|
||||
cargo run cibus_bin/
|
||||
cargo run cibus-backend/
|
||||
|
Loading…
x
Reference in New Issue
Block a user