WIP add password file
This commit is contained in:
parent
628f9eefc3
commit
7239578f95
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue