Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
90
.drone.yml
90
.drone.yml
@ -1,2 +1,88 @@
|
|||||||
kind: template
|
kind: pipeline
|
||||||
load: cuddle-rust-service-plan.yaml
|
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: {}
|
||||||
|
|
||||||
|
|
||||||
|
2006
Cargo.lock
generated
2006
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"crates/*"
|
"cibus_bin"
|
||||||
]
|
]
|
||||||
resolver = "2"
|
|
||||||
|
18
cibus_bin/Cargo.toml
Normal file
18
cibus_bin/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[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"] }
|
@ -16,7 +16,6 @@ use async_graphql::{
|
|||||||
};
|
};
|
||||||
use graphql::CibusSchema;
|
use graphql::CibusSchema;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use tokio::net::TcpListener;
|
|
||||||
use tower_http::{cors::CorsLayer, trace::TraceLayer};
|
use tower_http::{cors::CorsLayer, trace::TraceLayer};
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(tracing_subscriber::EnvFilter::new(
|
.with(tracing_subscriber::EnvFilter::new(
|
||||||
std::env::var("RUST_LOG").unwrap_or_else(|_| {
|
std::env::var("RUST_LOG").unwrap_or_else(|_| {
|
||||||
"cibus-backend=debug,tower_http=debug,axum_extra=debug,hyper=info,mio=info".into()
|
"cibus_bin=debug,tower_http=debug,axum_extra=debug,hyper=info,mio=info".into()
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
.with(tracing_subscriber::fmt::layer())
|
.with(tracing_subscriber::fmt::layer())
|
||||||
@ -78,9 +77,8 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
tracing::info!("Starting webserver");
|
tracing::info!("Starting webserver");
|
||||||
|
axum::Server::bind(&"0.0.0.0:3001".parse().unwrap())
|
||||||
let listener = TcpListener::bind("0.0.0.0:3001").await?;
|
.serve(app.into_make_service())
|
||||||
axum::serve(listener, app.into_make_service())
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
[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"] }
|
|
17
cuddle.yaml
17
cuddle.yaml
@ -1,23 +1,10 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# 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-service-plan.git"
|
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "cibus-backend"
|
service: "cibus-backend"
|
||||||
registry: kasperhermansen
|
deployments: "git@git.front.kjuulh.io:cibus/deployments.git"
|
||||||
|
|
||||||
clusters:
|
|
||||||
clank-prod:
|
|
||||||
replicas: "3"
|
|
||||||
namespace: prod
|
|
||||||
|
|
||||||
|
|
||||||
deployment:
|
|
||||||
registry: git@git.front.kjuulh.io:kjuulh/clank-clusters
|
|
||||||
env:
|
|
||||||
prod:
|
|
||||||
clusters:
|
|
||||||
- clank-prod
|
|
||||||
|
|
||||||
scripts:
|
scripts:
|
||||||
render_cibus_templates:
|
render_cibus_templates:
|
||||||
|
120
local.sh
Executable file
120
local.sh
Executable file
@ -0,0 +1,120 @@
|
|||||||
|
#!/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
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
|
||||||
}
|
|
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cargo run cibus-backend/
|
cargo run cibus_bin/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user