Docker changes #31

Merged
phoenix merged 19 commits from docker_changes into devel 2025-04-13 18:38:40 +00:00
4 changed files with 23 additions and 14 deletions
Showing only changes of commit 6b12421e7c - Show all commits

View File

@@ -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/

View File

@@ -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

View File

@@ -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

View File

@@ -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) {