diff --git a/Dockerfile b/Dockerfile index df68204..e258be1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM rust:1.86.0 as build +FROM rust:alpine as build ENV PKG_CONFIG_ALLOW_CROSS=1 ENV SCCACHE_DIR=/build-cache ENV RUSTC_WRAPPER=sccache -RUN apt update && apt install sccache +RUN apk add pkgconfig openssl-dev libc-dev openssl-libs-static sccache WORKDIR . COPY ./api ./api @@ -16,8 +16,20 @@ COPY ./api/templates ./templates RUN cd api && cargo build --release +FROM alpine:latest +WORKDIR /app +RUN apk update \ + && apk add openssl ca-certificates + +EXPOSE 8080 +COPY --from=build /api/target/release/septastic_api /app/septastic_api +COPY api/assets /app/assets +COPY api/templates /app/templates + ENV RUST_LOG=info ENV EXPOSE_PORT=8080 -EXPOSE 8080 -ENTRYPOINT ["/api/target/release/septastic_api"] +RUN ls -lah +RUN pwd + +ENTRYPOINT ["./septastic_api"] diff --git a/api/src/database.rs b/api/src/database.rs index 2cd397d..829b234 100644 --- a/api/src/database.rs +++ b/api/src/database.rs @@ -98,7 +98,7 @@ pub async fn get_schedule_by_route_id( ) -> ::anyhow::Result> { let schedule_day = chrono::Utc::now().with_timezone(&chrono_tz::America::New_York); - let schedule_day_str = schedule_day.format("YYYYMMDD").to_string(); + let schedule_day_str = schedule_day.format("%Y%m%d").to_string(); let rows = sqlx::query!( r#"SELECT @@ -125,8 +125,8 @@ pub async fn get_schedule_by_route_id( AND service_id IN (SELECT service_id FROM septa_schedule_days WHERE date = $2) ;"#, - id, - schedule_day_str + id.clone(), + schedule_day_str.clone() ) .fetch_all(&mut **transaction) .await?; @@ -228,7 +228,7 @@ pub async fn get_nta_by_stop_id( let end_secs = local_end.signed_duration_since(local_midnight).num_seconds(); let schedule_day = chrono::Utc::now().with_timezone(&chrono_tz::America::New_York); - let schedule_day_str = schedule_day.format("YYYYMMDD").to_string(); + let schedule_day_str = schedule_day.format("%Y%m%d").to_string(); let name_row = sqlx::query!("SELECT name FROM septa_stops WHERE id = $1", ids[0]).fetch_one(&mut **transaction).await?;