Skip to content

Commit

Permalink
Include binary in Dockerfile, default info log
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Sep 18, 2024
1 parent eb2e75d commit 361800c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ RUN --mount=type=bind,source=src,target=src \
--mount=type=cache,target=/app/target/ \
--mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo build --locked --release --bin $APP_NAME && \
cp ./target/release/$APP_NAME /bin/server
cargo build --locked --release --bin $APP_NAME --bin pagerank && \
cp ./target/release/$APP_NAME /bin/server && \
cp ./target/release/pagerank /bin/pagerank

################################################################################
# Create a new stage for running the application that contains the minimal
Expand All @@ -51,6 +52,7 @@ USER appuser

# Copy the executables from the "build" stage.
COPY --from=build /bin/server /bin/
COPY --from=build /bin/pagerank /bin/

# Copy any necessary configuration or migration files
COPY ./migrations /app/migrations
Expand Down
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
context: .
target: final
environment:
- APP__followers__relay=ws://relay:7777
- APP__followers__neo4j_uri=db:7687
- APP__followers__neo4j_user=neo4j
- APP__followers__neo4j_password=mydevpassword
Expand Down
7 changes: 1 addition & 6 deletions src/bin/pagerank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ use tracing_subscriber::{fmt, prelude::*, EnvFilter};

#[tokio::main]
async fn main() -> Result<()> {
// Initialize logging
tracing_subscriber::registry()
.with(fmt::layer())
.with(EnvFilter::from_default_env())
.with(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")))
.init();

info!("PageRank updater started");

// Load configuration
let config = Config::new("config").context("Loading configuration failed")?;
let settings = config
.get::<Settings>()
.context("Retrieving settings from configuration failed")?;

// Connect to Neo4j
info!("Connecting to Neo4j at {}", settings.neo4j_uri);
let graph = Graph::new(
&settings.neo4j_uri,
Expand All @@ -34,10 +31,8 @@ async fn main() -> Result<()> {
.await
.context("Failed to connect to Neo4j")?;

// Initialize Repo
let repo = Arc::new(Repo::new(graph));

// Execute PageRank
info!("Executing PageRank update");
if let Err(e) = repo.update_pagerank().await {
error!("PageRank update failed: {:?}", e);
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tracing_subscriber::{fmt, prelude::*, EnvFilter};
async fn main() -> Result<()> {
tracing_subscriber::registry()
.with(fmt::layer())
.with(EnvFilter::from_default_env())
.with(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")))
.init();

ring::default_provider()
Expand Down

0 comments on commit 361800c

Please sign in to comment.