diff --git a/.dockerignore.yaml b/.dockerignore.yaml index 9b144ce..dc3b873 100644 --- a/.dockerignore.yaml +++ b/.dockerignore.yaml @@ -7,6 +7,8 @@ pkg/ # Ignore environment files (configure via docker-compose instead) .env* +auth_db.env* +auth_db.env.docker* # Ignore IDE/editor specific files .idea/ diff --git a/Dockerfile b/Dockerfile index de67ef8..4f3a66d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,8 @@ RUN --mount=type=ssh mkdir src && \ COPY src ./src # If you have other directories like `templates` or `static`, copy them too COPY .env ./.env -COPY auth_db.env ./auth_db.env +# COPY auth_db.env.docker ./auth_db.env +COPY auth_db.env.docker ./auth_db.env COPY migrations ./migrations # << --- SSH MOUNT ADDED HERE --- >> @@ -62,6 +63,8 @@ COPY --from=builder /usr/src/app/target/release/icarus_auth . # 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 COPY --from=builder /usr/src/app/.env . +# COPY --from=builder /usr/src/app/auth_db.env.docker auth_db.env +# COPY --from=builder /usr/src/app/auth_db.env.docker ./auth_db.env COPY --from=builder /usr/src/app/auth_db.env . COPY --from=builder /usr/src/app/migrations ./migrations diff --git a/docker-compose.yaml b/docker-compose.yaml index 8790d65..ddd4567 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -20,6 +20,7 @@ services: # APP_PORT: 3000 env_file: - .env + # - auth_db.env depends_on: auth_db: condition: service_healthy # Wait for the DB to be healthy before starting the app @@ -29,13 +30,13 @@ services: auth_db: image: postgres:17.4-alpine # Use an official Postgres image (Alpine variant is smaller) container_name: icarus_auth_db # Optional: Give the container a specific name - # environment: + environment: # These MUST match the user, password, and database name in the DATABASE_URL above - # POSTGRES_USER: icarus_op - # POSTGRES_PASSWORD: password - # POSTGRES_DB: icarus_auth - env_file: - - auth_db.env + POSTGRES_USER: ${POSTGRES_USER:-icarus_op} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password} + POSTGRES_DB: ${POSTGRES_DB:-icarus_auth} + # env_file: + # - auth_db.env.docker volumes: # Persist database data using a named volume - postgres_data:/var/lib/postgresql/data diff --git a/src/lib.rs b/src/lib.rs index 33cb7af..d97813f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,13 +36,16 @@ pub mod db { async fn get_db_url() -> String { #[cfg(debug_assertions)] // Example: Only load .env in debug builds dotenvy::dotenv().ok(); - match dotenvy::from_filename("auth_db.env") { - Ok(_) => env::var(keys::DBURL).expect(keys::error::ERROR), - Err(err) => { - eprintln!("Error loading db env files {:?}", err); - String::new() - } - } + env::var(keys::DBURL).expect(keys::error::ERROR) + /* + match dotenvy::from_filename("auth_db.env") { + Ok(_) => + Err(err) => { + eprintln!("Error loading db env files {:?}", err); + String::new() + } + } + */ } pub async fn migrations(pool: &sqlx::PgPool) {