Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Director #3

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/director-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build director image

on:
push:
branches:
- main
paths:
- "director/**"
- ".github/workflows/build-director.yaml"

jobs:
build-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/m1guelpf/dyson-director
tags: |
type=sha
type=edge
type=semver,pattern={{major}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
context: ./director
cache-from: type=gha
file: ./director/Dockerfile
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 0 additions & 1 deletion api/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.env
target
src/db
Dockerfile
.dockerignore
1 change: 0 additions & 1 deletion api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.env
target/
src/db
5 changes: 2 additions & 3 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[package]
publish = false
edition = "2021"
version = "0.0.0"
name = "dyson-api"
edition = "2021"
default-run = "dyson-api"

[dependencies]
url = { version = "2.4.0", features = ["serde"] }
anyhow = "1.0.72"
tracing = "0.1.37"
dotenvy = "0.15.7"
serde_json = "1.0.104"
url = { version = "2.4.0", features = ["serde"] }
aide = { version = "0.11.0", features = ["axum"] }
tokio = { version = "1.29.1", features = ["full"] }
serde = { version = "1.0.171", features = ["derive"] }
Expand Down
32 changes: 16 additions & 16 deletions api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ use chrono::prelude::{DateTime, Utc};
use std::process::Command;

fn get_git_rev() -> Option<String> {
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()?;
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()?;

if output.status.success() {
String::from_utf8(output.stdout).ok()
} else {
None
}
if output.status.success() {
String::from_utf8(output.stdout).ok()
} else {
None
}
}

fn get_compile_date() -> String {
let system_time = std::time::SystemTime::now();
let date_time: DateTime<Utc> = system_time.into();
format!("{}", date_time.format("%+"))
let system_time = std::time::SystemTime::now();
let date_time: DateTime<Utc> = system_time.into();
format!("{}", date_time.format("%+"))
}

fn main() {
println!("cargo:rustc-env=STATIC_BUILD_DATE={}", get_compile_date());
println!("cargo:rustc-env=STATIC_BUILD_DATE={}", get_compile_date());

if let Some(rev) = get_git_rev() {
println!("cargo:rustc-env=GIT_REV={}", rev);
}
if let Some(rev) = get_git_rev() {
println!("cargo:rustc-env=GIT_REV={}", rev);
}
}
4 changes: 4 additions & 0 deletions director/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
target
Dockerfile
.dockerignore
2 changes: 2 additions & 0 deletions director/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
target/
Loading