Skip to content

Commit f2ee166

Browse files
YaroslavLitvinovnikitastryukgithub-actions[bot]
authored andcommitted
Yaro/slatedb durability config2 (#1773)
* update slatedb to v0.8.2 * use less durable but faster option when put history items * [UI] Static hostname issue fix (Run-time Placeholder solution) (#1770) * CI: Generate build artifacts (dist.tar) [skip ci] --------- Co-authored-by: Nikita Striuk <32720808+nikitastryuk@users.noreply.github.com> Co-authored-by: github-actions[bot] <1310417+github-actions[bot]@users.noreply.github.com>
1 parent 9f02ea8 commit f2ee166

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,28 @@ RUN apt-get update && apt-get install -y \
1111
ca-certificates \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14-
# Copy source code
14+
# Copy all source code, including the pre-built frontend and entrypoint script
1515
COPY . .
1616

1717
# Build the application with optimizations
1818
RUN cargo build --release --bin embucketd
1919

20-
# Stage 4: Final runtime image
20+
# Stage 2: Final runtime image
2121
FROM gcr.io/distroless/cc-debian12 AS runtime
2222

23-
# Set working directory
24-
USER nonroot:nonroot
2523
WORKDIR /app
2624

27-
# Copy the binary and required files
25+
# Copy the compiled binary, API spec, frontend build, and entrypoint script
2826
COPY --from=builder /app/target/release/embucketd ./embucketd
2927
COPY --from=builder /app/rest-catalog-open-api.yaml ./rest-catalog-open-api.yaml
28+
COPY --from=builder /app/frontend/dist ./dist
29+
COPY --from=builder /app/entrypoint.sh /usr/local/bin/entrypoint.sh
30+
31+
# Make the script executable and ensure the nonroot user can modify app files
32+
RUN chmod +x /usr/local/bin/entrypoint.sh && chown -R nonroot:nonroot /app
33+
34+
# Switch to a non-privileged user
35+
USER nonroot:nonroot
3036

3137
# Expose port (adjust as needed)
3238
EXPOSE 8080
@@ -37,5 +43,7 @@ ENV FILE_STORAGE_PATH=data/
3743
ENV BUCKET_HOST=0.0.0.0
3844
ENV JWT_SECRET=63f4945d921d599f27ae4fdf5bada3f1
3945

40-
# Default command
46+
# Set the entrypoint to our script
47+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
48+
4149
CMD ["./embucketd"]

crates/core-utils/src/lib.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use serde_json::de;
1313
use serde_json::ser;
1414
use slatedb::Db as SlateDb;
1515
use slatedb::DbIterator;
16-
// use slatedb::config::{PutOptions, WriteOptions};
16+
use slatedb::config::{PutOptions, WriteOptions};
1717
use snafu::location;
1818
use snafu::prelude::*;
1919
use std::fmt::Debug;
@@ -150,18 +150,24 @@ impl Db {
150150
entity: &T,
151151
) -> Result<()> {
152152
let serialized = ser::to_vec(entity).context(errors::SerializeValueSnafu)?;
153-
self.0
153+
#[cfg(feature = "none-durable-history-write")]
154+
let result = self.0
155+
.put_with_options(
156+
entity.key().as_ref(),
157+
serialized,
158+
&PutOptions::default(),
159+
&WriteOptions {
160+
await_durable: false,
161+
},
162+
)
163+
.await
164+
.context(errors::DatabaseSnafu);
165+
#[cfg(not(feature = "none-durable-history-write"))]
166+
let result = self.0
154167
.put(entity.key().as_ref(), serialized)
155-
// .put_with_options(
156-
// entity.key().as_ref(),
157-
// serialized,
158-
// &PutOptions::default(),
159-
// &WriteOptions {
160-
// await_durable: false,
161-
// },
162-
// )
163168
.await
164-
.context(errors::DatabaseSnafu)
169+
.context(errors::DatabaseSnafu);
170+
result
165171
}
166172

167173
/// Iterator for iterating in range

entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
set -e
3+
4+
INDEX_FILE=/app/dist/index.html
5+
6+
# Use the provided API_URL or default to http://localhost:3000 if it's not set
7+
FINAL_API_URL=${API_URL:-http://localhost:3000}
8+
9+
echo "Setting API URL to $FINAL_API_URL in $INDEX_FILE"
10+
11+
# Use sed to replace the placeholder with the actual API_URL.
12+
sed -i "s#__API_URL__#$FINAL_API_URL#g" $INDEX_FILE
13+
14+
exec "$@"

0 commit comments

Comments
 (0)