Skip to content

Commit 736b5d7

Browse files
committed
Made more docker friendly
1 parent 808dcd1 commit 736b5d7

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

Dockerfile

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,40 @@ RUN --mount=type=bind,source=src,target=src \
3535
# Create a new stage for running the application with minimal runtime dependencies
3636
FROM debian:bookworm-slim AS final
3737

38+
# Install SSL library
39+
RUN apt-get update && apt-get install -y libssl3 && rm -rf /var/lib/apt/lists/*
40+
41+
# Copy the CPIs directory from the source to the final image
42+
COPY ./CPIs /CPIs
43+
44+
# Copy the executable from the "build" stage.
45+
COPY --from=build /bin/server /bin/
46+
3847
# Create a non-privileged user that the app will run under.
3948
ARG UID=10001
4049
RUN adduser \
41-
--disabled-password \
42-
--gecos "" \
43-
--home "/nonexistent" \
44-
--shell "/sbin/nologin" \
45-
--no-create-home \
46-
--uid "${UID}" \
47-
appuser
50+
--disabled-password \
51+
--gecos "" \
52+
--home "/nonexistent" \
53+
--shell "/sbin/nologin" \
54+
--no-create-home \
55+
--uid "${UID}" \
56+
appuser
4857

49-
USER appuser
58+
# Fix permissions on the CPIs dir
59+
RUN chmod -R a+rx /CPIs && \
60+
chown -R appuser:appuser /CPIs
5061

51-
# Copy the executable from the "build" stage.
52-
COPY --from=build /bin/server /bin/
62+
# Fix permissions on the /bin dir
63+
RUN chmod 777 /bin/server && \
64+
chown -R appuser:appuser /bin/server
65+
66+
# fix log file permissions
67+
RUN touch /bin/server.log && \
68+
chmod a+rwx /bin/server.log && \
69+
chown -R appuser:appuser /bin/server.log
70+
71+
USER appuser
5372

5473
# Expose the port that the application listens on.
5574
EXPOSE 3000

src/cpis/loader.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ pub fn load_cpis() -> DashMap<String, String> {
66

77
let entries = match std::fs::read_dir(cpi_dir) {
88
Ok(iter) => iter,
9-
Err(_) => return DashMap::new(),
9+
Err(e) => {
10+
eprintln!("Error reading directory: {}", cpi_dir);
11+
eprintln!("Error: {}", e);
12+
return DashMap::new();
13+
}
1014
};
1115

1216
let paths: Vec<_> = entries

src/cpis/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ impl CpiSystem {
117117
// Load CPIs using the loader module
118118
let cpis = Arc::new(loader::load_cpis());
119119
let total_cpis = cpis.len();
120+
121+
println!("Total CPIs found: {}", total_cpis);
120122

121123
// Use a concurrent HashSet for tracking valid CPIs
122124
let valid_cpis = DashMap::new();

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use anyhow::Result;
88

99
#[tokio::main]
1010
async fn main() -> Result<()> {
11-
ez_logging::init()?;
12-
1311
// Initialize the CPI system
12+
println!("Initializing CPI system...");
1413
let cpi_system = cpis::initialize()?;
1514

1615
// List available providers

0 commit comments

Comments
 (0)