Saving changes
Some checks failed
Rust Build / Check (pull_request) Successful in 44s
Rust Build / Test Suite (pull_request) Successful in 59s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 49s
Rust Build / build (pull_request) Successful in 1m20s
Some checks failed
Rust Build / Check (pull_request) Successful in 44s
Rust Build / Test Suite (pull_request) Successful in 59s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 49s
Rust Build / build (pull_request) Successful in 1m20s
This commit is contained in:
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.env
|
||||||
|
!/.env.docker
|
@@ -34,9 +34,14 @@ RUN --mount=type=ssh mkdir src && \
|
|||||||
# Copy the actual source code
|
# Copy the actual source code
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
# If you have other directories like `templates` or `static`, copy them too
|
# If you have other directories like `templates` or `static`, copy them too
|
||||||
COPY .env.docker ./.env
|
COPY .env.docker ./.env.docker
|
||||||
COPY migrations ./migrations
|
COPY migrations ./migrations
|
||||||
|
|
||||||
|
# Explicitly expose the env var
|
||||||
|
# ENV DATABASE_URL=${DATABASE_URL}
|
||||||
|
ARG ENV_FILE=.env.docker
|
||||||
|
COPY ${ENV_FILE} ./.env.docker
|
||||||
|
|
||||||
# << --- SSH MOUNT ADDED HERE --- >>
|
# << --- SSH MOUNT ADDED HERE --- >>
|
||||||
# Build *only* dependencies to leverage Docker cache
|
# Build *only* dependencies to leverage Docker cache
|
||||||
# This dummy build caches dependencies as a separate layer
|
# This dummy build caches dependencies as a separate layer
|
||||||
@@ -60,7 +65,7 @@ COPY --from=builder /usr/src/app/target/release/icarus_auth .
|
|||||||
|
|
||||||
# Copy other necessary files like .env (if used for runtime config) or static assets
|
# Copy other necessary files like .env (if used for runtime config) or static assets
|
||||||
# It's generally better to configure via environment variables in Docker though
|
# It's generally better to configure via environment variables in Docker though
|
||||||
COPY --from=builder /usr/src/app/.env .
|
COPY --from=builder /usr/src/app/.env.docker .
|
||||||
COPY --from=builder /usr/src/app/migrations ./migrations
|
COPY --from=builder /usr/src/app/migrations ./migrations
|
||||||
|
|
||||||
# Expose the port your Axum app listens on (e.g., 3000 or 8000)
|
# Expose the port your Axum app listens on (e.g., 3000 or 8000)
|
||||||
|
@@ -11,7 +11,9 @@ services:
|
|||||||
# Map host port 8000 to container port 3000 (adjust as needed)
|
# Map host port 8000 to container port 3000 (adjust as needed)
|
||||||
- "8000:3000"
|
- "8000:3000"
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env.docker
|
||||||
|
environment:
|
||||||
|
- DATABASE_URL=${DATABASE_URL}
|
||||||
depends_on:
|
depends_on:
|
||||||
auth_db:
|
auth_db:
|
||||||
condition: service_healthy # Wait for the DB to be healthy before starting the app
|
condition: service_healthy # Wait for the DB to be healthy before starting the app
|
||||||
|
21
src/lib.rs
21
src/lib.rs
@@ -19,7 +19,6 @@ mod connection_settings {
|
|||||||
pub mod db {
|
pub mod db {
|
||||||
|
|
||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
use std::env;
|
|
||||||
|
|
||||||
use crate::{connection_settings, keys};
|
use crate::{connection_settings, keys};
|
||||||
|
|
||||||
@@ -34,9 +33,25 @@ pub mod db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_db_url() -> String {
|
async fn get_db_url() -> String {
|
||||||
dotenvy::dotenv().ok();
|
// dotenvy::dotenv().ok();
|
||||||
// dotenvy::from_filename(".env").ok();
|
// dotenvy::from_filename(".env").ok();
|
||||||
env::var(keys::DBURL).expect(keys::error::ERROR)
|
// env::var(keys::DBURL).expect(keys::error::ERROR)
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::env::var(keys::DBURL)
|
||||||
|
.or_else(|_| {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
dotenvy::var(keys::DBURL)
|
||||||
|
})
|
||||||
|
.expect("DATABASE_URL must be set in environment or .env file")
|
||||||
|
*/
|
||||||
|
if let Err(_) = dotenvy::from_filename(".env.docker") {
|
||||||
|
eprintln!("Note: .env.docker not found, using system env vars");
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
std::env::var(keys::DBURL).expect(keys::error::ERROR)
|
||||||
|
} else {
|
||||||
|
std::env::var(keys::DBURL).expect(keys::error::ERROR)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn migrations(pool: &sqlx::PgPool) {
|
pub async fn migrations(pool: &sqlx::PgPool) {
|
||||||
|
Reference in New Issue
Block a user