Skip to content

Commit a59a6e8

Browse files
authored
Merge pull request #20 from jdhoffa/fix_api
fix(api): don't expect a `.env` file when run through Docker container
2 parents 8d551ef + 35e0f7d commit a59a6e8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ RUN touch .env && \
3939
echo "DATABASE_URL=\${DATABASE_URL:-postgres://postgres:postgres@db:5432/pbtar}" > .env && \
4040
echo "RUST_LOG=\${RUST_LOG:-info}" >> .env
4141

42-
EXPOSE 8080
42+
EXPOSE 8000
4343

4444
CMD ["/app/lucidata-api"]

api/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
1414

1515
#[tokio::main]
1616
async fn main() {
17-
// Load environment variables
18-
dotenv().ok();
17+
// Load environment variables, don't require .env file in Docker
18+
let _ = dotenv();
1919

2020
// Initialize logging
2121
tracing_subscriber::registry()
@@ -29,11 +29,15 @@ async fn main() {
2929
let database_url = env::var("DATABASE_URL")
3030
.expect("DATABASE_URL must be set");
3131

32+
tracing::info!("Connecting to database...");
33+
3234
let pool = PgPoolOptions::new()
3335
.max_connections(5)
3436
.connect(&database_url)
3537
.await
3638
.expect("Failed to create pool");
39+
40+
tracing::info!("Successfully connected to database");
3741

3842
// CORS configuration
3943
let cors = CorsLayer::new()

0 commit comments

Comments
 (0)