diff --git a/Dockerfile b/Dockerfile index 228d541..1086e81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM rust:alpine3.17 as builder +ARG RELEASE_BUILD=true + # update packages RUN apk update RUN apk add build-base openssl-dev ca-certificates @@ -17,13 +19,13 @@ WORKDIR /app/src # Build dependencies only. Separate these for caches RUN cargo install cargo-build-deps -RUN cargo build-deps --release +RUN sh -c "cargo build-deps ${RELEASE_BUILD:+ --release}" # Build the release executable. -RUN cargo build --release +RUN sh -c "cargo build ${RELEASE_BUILD:+ --release}" # Runner stage. I tried using distroless (gcr.io/distroless/static-debian11), but the image was only ~3MBs smaller than -# alpine. I chose to use alpine since a user can easily be added to the image. +# alpine. I chose to use alpine since it makes it easier to exec into the container to debug things. FROM alpine:3.17 ARG UNAME=orca-registry @@ -34,6 +36,7 @@ ARG GID=1000 RUN adduser --disabled-password --gecos "" $UNAME -s -G $GID -u $UID COPY --from=builder --chown=$UID:$GID /app/src/target/release/orca-registry /app/orca-registry +# Chown everything RUN mkdir /data && \ chown -R $UID:$GID /data && \ chown -R $UID:$GID /app diff --git a/src/api/blobs.rs b/src/api/blobs.rs index 39c30b1..3d2d9ee 100644 --- a/src/api/blobs.rs +++ b/src/api/blobs.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use axum::body::StreamBody; use axum::extract::{State, Path}; -use axum::http::{StatusCode, header, HeaderName, HeaderMap, HeaderValue}; +use axum::http::{StatusCode, header, HeaderName, HeaderMap}; use axum::response::{IntoResponse, Response}; use tokio_util::io::ReaderStream; use tracing::debug; diff --git a/src/main.rs b/src/main.rs index 437822c..fbbadb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,12 +28,13 @@ use tower_layer::Layer; use sqlx::sqlite::{SqlitePoolOptions, SqliteConnectOptions, SqliteJournalMode}; use tokio::sync::Mutex; use tower_http::normalize_path::NormalizePathLayer; +use tracing::metadata::LevelFilter; use tracing::{debug, info}; use app_state::AppState; use database::Database; use tracing_subscriber::filter; -use tracing_subscriber::{filter::FilterFn, layer::{Layer as TracingLayer, SubscriberExt}, util::SubscriberInitExt,}; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use crate::storage::StorageDriver; use crate::storage::filesystem::FilesystemDriver; @@ -81,6 +82,7 @@ async fn main() -> anyhow::Result<()> { .with(tracing_subscriber::fmt::layer()) .with(filter::Targets::new() .with_target("orca_registry", config.log_level) + .with_default(LevelFilter::INFO) ) .init(); } else {