WIP add password file
Some checks are pending
API Checks / clippy (push) Waiting to run
Deploy API / Deploy to Fly.io (push) Waiting to run

This commit is contained in:
D. Scott Boggs 2025-05-05 07:18:21 -04:00
parent 628f9eefc3
commit 7239578f95
2 changed files with 14 additions and 3 deletions

View file

@ -11,7 +11,7 @@ COPY . .
# Will build and cache the binary and dependent crates in release mode
RUN --mount=type=cache,target=/usr/local/cargo,from=rust:latest,source=/usr/local/cargo \
--mount=type=cache,target=target \
cargo build --release --features datastore-adaptor && mv ./target/release/crabfit-api ./api
cargo build --release --features sql-adaptor && mv ./target/release/crabfit-api ./api
# Runtime image
FROM debian:bullseye-slim

View file

@ -180,11 +180,22 @@ async fn get_stats_row(db: &DatabaseConnection) -> Result<stats::ActiveModel, Db
})
}
impl SqlAdaptor {
pub async fn new() -> Self {
fn get_connection_string() -> String {
let connection_string =
env::var("DATABASE_URL").expect("Expected DATABASE_URL environment variable");
if let Some(password_file_location) = env::var("DATABASE_PASSWORD_FILE") {
} else {
connection_string
}
}
impl SqlAdaptor {
pub async fn new() -> Self {
let connection_string = get_connection_string();
// Connect to the database
let db = Database::connect(&connection_string)
.await