Skip to content

Commit 92f699b

Browse files
committed
Fix:A bunch of tiny improvements here and there
1 parent 93fddb1 commit 92f699b

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

Dockerfile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66
FROM rustlang/rust:nightly-bullseye-slim AS builder
77
WORKDIR /app
88

9-
# Install build dependencies.
9+
# Install build dependencies
1010
RUN apt-get update && \
1111
apt-get install -y pkg-config libssl-dev && \
1212
rm -rf /var/lib/apt/lists/*
1313

14-
# Copy Cargo manifests and cache dependencies.
14+
# Copy Cargo manifests and cache dependencies
1515
COPY Cargo.toml Cargo.lock ./
1616

17-
# Create a dummy main file to allow dependency caching.
17+
# Create a dummy main file to allow dependency caching
1818
RUN mkdir src && echo "fn main() {}" > src/main.rs
1919

20-
# Build a dummy release binary (to cache dependencies).
20+
# Build a dummy release binary (to cache dependencies)
2121
RUN cargo build --release
2222

23-
# Now copy the full source code.
24-
COPY . .
23+
# Copy the full source code, including dashboard.html
24+
COPY src/ src/
2525

26-
# Build the real release binary.
26+
# Build the real release binary
2727
RUN cargo build --release
2828

2929
##############################
@@ -32,30 +32,30 @@ RUN cargo build --release
3232
FROM ubuntu:20.04
3333
WORKDIR /app
3434

35-
# Install runtime dependencies.
35+
# Install runtime dependencies
3636
RUN apt-get update && \
3737
apt-get install -y ca-certificates libssl1.1 && \
3838
rm -rf /var/lib/apt/lists/*
3939

40-
# Create a non-root user.
40+
# Create a non-root user
4141
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
4242

43-
# Create and set permissions for directories.
43+
# Create and set permissions for directories
4444
RUN mkdir -p /app/queue_db /app/data && \
4545
chown -R appuser:appgroup /app /app/queue_db /app/data && \
4646
chmod -R 775 /app /app/queue_db /app/data
4747

48-
# Copy the compiled binary from the builder stage.
48+
# Copy the compiled binary from the builder stage
4949
COPY --from=builder /app/target/release/timefusion /usr/local/bin/timefusion
5050

51-
# Adjust ownership of the binary.
51+
# Adjust ownership of the binary
5252
RUN chown appuser:appgroup /usr/local/bin/timefusion
5353

54-
# Expose the required ports.
55-
EXPOSE 8080 5432
54+
# Expose the required ports
55+
EXPOSE 80 5432
5656

57-
# Switch to the non-root user.
57+
# Switch to the non-root user
5858
USER appuser
5959

60-
# Start the application.
60+
# Start the application
6161
ENTRYPOINT ["/usr/local/bin/timefusion"]

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use anyhow::Context;
2727
use metrics::{UPTIME_GAUGE, COMPACTION_COUNTER, HTTP_REQUEST_COUNTER, INGESTION_COUNTER, ERROR_COUNTER};
2828
use prometheus::core::Collector;
2929
use std::collections::HashMap;
30-
use std::fs;
3130

3231
#[get("/dashboard")]
3332
async fn dashboard(
@@ -135,7 +134,7 @@ async fn dashboard(
135134
}
136135
};
137136

138-
let html = fs::read_to_string("./src/dashboard/dashboard.html").expect("Failed to read dashboard.html")
137+
let html = include_str!("dashboard/dashboard.html")
139138
.replace("{{uptime}}", &uptime.to_string())
140139
.replace("{{compactions}}", &compactions.to_string())
141140
.replace("{{http_requests}}", &http_requests.to_string())

0 commit comments

Comments
 (0)