Skip to content

Commit

Permalink
Pairing fixes (#155)
Browse files Browse the repository at this point in the history
- Add ca-cert package to Docker image
- Add debugging tools to Docker image
- Add error source to snap_name lookup call
- Add Makefile command for building Docker container from folder (I kept
getting it wrong)
  • Loading branch information
matthew-hagemann authored Jan 14, 2025
2 parents 897b0bc + 5bb716b commit 4371ecd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
build:
@cargo build --release

.PHONY: docker-build
docker-build:
@docker build -f docker/prod/Dockerfile .

.PHONY: up
up:
@docker-compose up
Expand Down
8 changes: 7 additions & 1 deletion docker/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM ubuntu:latest

RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl-dev \
jq \
curl \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY target/release/ratings /app/ratings

EXPOSE 443
ENTRYPOINT ["/app/ratings"]

13 changes: 11 additions & 2 deletions src/grpc/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
ratings::{get_snap_name, Rating},
Context,
};
use std::sync::Arc;
use std::{error::Error, sync::Arc};
use tonic::{Request, Response, Status};
use tracing::error;

Expand Down Expand Up @@ -52,7 +52,16 @@ impl App for RatingService {
&self.ctx.http_client,
)
.await
.map_err(|_| Status::unknown("Internal server error"))?;
.map_err(|e| {
let mut err = &e as &dyn Error;
let mut error = format!("{err}");
while let Some(src) = err.source() {
error.push_str(&format!("\n\nCaused by: {src}"));
err = src;
}
error!(%error, "unable to fetch snap name");
Status::unknown("Internal server error")
})?;

Ok(Response::new(GetRatingResponse {
rating: Some(PbRating {
Expand Down

0 comments on commit 4371ecd

Please sign in to comment.