Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3504842
D5725.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D5725.diff
View Options
diff --git a/.dockerignore b/.dockerignore
--- a/.dockerignore
+++ b/.dockerignore
@@ -33,6 +33,7 @@
services/identity/target
services/identity/Dockerfile
services/backup/Dockerfile
+services/blob/target
services/blob/Dockerfile
native/cpp/**/build
diff --git a/services/blob/Cargo.toml b/services/blob/Cargo.toml
--- a/services/blob/Cargo.toml
+++ b/services/blob/Cargo.toml
@@ -5,7 +5,6 @@
license = "BSD-3-Clause"
version = "0.1.0"
edition = "2021"
-links = "blob"
[dependencies]
anyhow = "1.0"
diff --git a/services/blob/Dockerfile b/services/blob/Dockerfile
--- a/services/blob/Dockerfile
+++ b/services/blob/Dockerfile
@@ -1,25 +1,44 @@
-FROM commapp/services-base:1.3.2
+FROM commapp/services-base:1.3.2 as builder
-RUN apt-get update && \
- apt-get install -y uuid-dev && \
- rm -rf /var/lib/apt/lists/*
+ENV PATH=/root/.cargo/bin:$PATH
-ARG COMM_TEST_SERVICES
-ARG COMM_SERVICES_SANDBOX
+# Install Curl
+RUN apt-get update \
+ && DEBIAN_FRONTEND=noninteractive apt-get install -y curl \
+ && rm -rf /var/lib/apt/lists/*
-ENV COMM_TEST_SERVICES=${COMM_TEST_SERVICES}
-ENV COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX}
+# Install Rust
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
+
+RUN mkdir -p /home/comm/app/blob
+WORKDIR /home/comm/app/blob
+RUN cargo init --bin
+
+# Cache build dependencies in a new layer
+COPY services/blob/Cargo.toml services/blob/Cargo.lock ./
+RUN cargo build --release && rm src/*.rs
-WORKDIR /transferred
+# Copy actual application sources
+COPY services/blob .
+COPY shared/protos/blob.proto ../../shared/protos/
-COPY services/lib/docker/ scripts/
-COPY services/blob/old/ blob
-COPY services/lib/src lib/src/
+# Remove the previously-built binary so that only the application itself is
+# rebuilt
+RUN rm ./target/release/deps/blob*
+RUN cargo build --release
-WORKDIR /transferred/blob
+# Runner stage
+FROM commapp/services-base:1.3.2 as runner
-ADD shared/protos grpc
+# Create a new user comm and use it to run subsequent commands
+RUN useradd -m comm
+USER comm
-RUN ../scripts/build_service.sh
+# Only copy built binary from builder stage
+WORKDIR /home/comm/app/blob
+COPY --from=builder /home/comm/app/blob/target/release/blob .
+
+ARG COMM_SERVICES_SANDBOX
+ENV COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX}
-CMD if [ "$COMM_TEST_SERVICES" -eq 1 ]; then ../scripts/run_tests.sh; else ../scripts/run_service.sh; fi
+CMD ["./blob"]
diff --git a/services/blob/src/constants.rs b/services/blob/src/constants.rs
--- a/services/blob/src/constants.rs
+++ b/services/blob/src/constants.rs
@@ -2,7 +2,7 @@
pub const GRPC_SERVER_DEFAULT_PORT: u64 = 50051;
pub const AWS_REGION: &str = "us-east-2";
-pub const LOCALSTACK_URL: &str = "http://localhost:4566";
+pub const LOCALSTACK_URL: &str = "http://localstack:4566";
pub const MPSC_CHANNEL_BUFFER_CAPACITY: usize = 1;
/// 4MB limit
diff --git a/services/docker-compose.yml b/services/docker-compose.yml
--- a/services/docker-compose.yml
+++ b/services/docker-compose.yml
@@ -50,7 +50,8 @@
ports:
- "${COMM_SERVICES_PORT_BLOB}:50051"
volumes:
- - $HOME/.aws/credentials:/root/.aws/credentials:ro
+ - $HOME/.aws/config:/home/comm/.aws/config:ro
+ - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro
# identity
identity-server:
depends_on:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 10:46 AM (19 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2687455
Default Alt Text
D5725.diff (3 KB)
Attached To
Mode
D5725: [services][blob] Use Rust implementation in Dockerfile
Attached
Detach File
Event Timeline
Log In to Comment