Fixed docker issue

This commit is contained in:
2025-04-13 13:54:11 -04:00
parent 042fae7a8f
commit 6b12421e7c
4 changed files with 23 additions and 14 deletions

View File

@@ -7,6 +7,8 @@ pkg/
# Ignore environment files (configure via docker-compose instead) # Ignore environment files (configure via docker-compose instead)
.env* .env*
auth_db.env*
auth_db.env.docker*
# Ignore IDE/editor specific files # Ignore IDE/editor specific files
.idea/ .idea/

View File

@@ -35,7 +35,8 @@ RUN --mount=type=ssh mkdir src && \
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 ./.env 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 COPY migrations ./migrations
# << --- SSH MOUNT ADDED HERE --- >> # << --- 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 # 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 .
# 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/auth_db.env .
COPY --from=builder /usr/src/app/migrations ./migrations COPY --from=builder /usr/src/app/migrations ./migrations

View File

@@ -20,6 +20,7 @@ services:
# APP_PORT: 3000 # APP_PORT: 3000
env_file: env_file:
- .env - .env
# - auth_db.env
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
@@ -29,13 +30,13 @@ services:
auth_db: auth_db:
image: postgres:17.4-alpine # Use an official Postgres image (Alpine variant is smaller) 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 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 # These MUST match the user, password, and database name in the DATABASE_URL above
# POSTGRES_USER: icarus_op POSTGRES_USER: ${POSTGRES_USER:-icarus_op}
# POSTGRES_PASSWORD: password POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
# POSTGRES_DB: icarus_auth POSTGRES_DB: ${POSTGRES_DB:-icarus_auth}
env_file: # env_file:
- auth_db.env # - auth_db.env.docker
volumes: volumes:
# Persist database data using a named volume # Persist database data using a named volume
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data

View File

@@ -36,13 +36,16 @@ pub mod db {
async fn get_db_url() -> String { async fn get_db_url() -> String {
#[cfg(debug_assertions)] // Example: Only load .env in debug builds #[cfg(debug_assertions)] // Example: Only load .env in debug builds
dotenvy::dotenv().ok(); dotenvy::dotenv().ok();
match dotenvy::from_filename("auth_db.env") { env::var(keys::DBURL).expect(keys::error::ERROR)
Ok(_) => env::var(keys::DBURL).expect(keys::error::ERROR), /*
Err(err) => { match dotenvy::from_filename("auth_db.env") {
eprintln!("Error loading db env files {:?}", err); Ok(_) =>
String::new() Err(err) => {
} eprintln!("Error loading db env files {:?}", err);
} String::new()
}
}
*/
} }
pub async fn migrations(pool: &sqlx::PgPool) { pub async fn migrations(pool: &sqlx::PgPool) {