Page MenuHomePhabricator

D6262.diff
No OneTemporary

D6262.diff

diff --git a/services/backup/Dockerfile b/services/backup/Dockerfile
--- a/services/backup/Dockerfile
+++ b/services/backup/Dockerfile
@@ -1,30 +1,52 @@
-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
-# install rust
-RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+RUN mkdir -p /home/comm/app/backup
+WORKDIR /home/comm/app/backup
+RUN cargo init --bin
-WORKDIR /transferred/services/backup
+# Cache build dependencies in a new layer
+COPY services/backup/Cargo.toml services/backup/Cargo.lock ./
+RUN cargo build --release && rm src/*.rs
-COPY services/lib/docker/ scripts/
+# Copy actual application sources
+COPY services/backup .
+COPY shared/protos/backup.proto ../../shared/protos/
+COPY shared/protos/blob.proto ../../shared/protos/
-RUN scripts/install_corrosion.sh
+# Remove the previously-built binary so that only the application itself is
+# rebuilt
+RUN rm ./target/release/deps/backup*
+RUN cargo build --release
-ADD shared/protos /transferred/shared/protos/
-ADD shared/cmake /transferred/shared/cmake/
+# Runner stage
+FROM commapp/services-base:1.3.2 as runner
-COPY services/backup/old/ /transferred/services/backup/
-COPY services/lib/src/ /transferred/services/lib/src/
+# 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/backup
+COPY --from=builder /home/comm/app/backup/target/release/backup .
-CMD if [ "$COMM_TEST_SERVICES" -eq 1 ]; then scripts/run_tests.sh; else scripts/run_service.sh; fi
+ARG COMM_SERVICES_SANDBOX
+ENV COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX}
+ARG LOCALSTACK_URL
+ENV LOCALSTACK_URL=${LOCALSTACK_URL}
+ARG BLOB_SERVICE_URL
+ENV BLOB_SERVICE_URL=${BLOB_SERVICE_URL}
+
+CMD ./backup \
+ --localstack-url ${LOCALSTACK_URL} \
+ --blob-service-url ${BLOB_SERVICE_URL}
+ # The COMM_SERVICES_SANDBOX is processed by the executable
diff --git a/services/docker-compose.yml b/services/docker-compose.yml
--- a/services/docker-compose.yml
+++ b/services/docker-compose.yml
@@ -25,17 +25,20 @@
backup-server:
depends_on:
- localstack
+ - blob-server
build:
dockerfile: services/backup/Dockerfile
context: ../
args:
- COMM_TEST_SERVICES=${COMM_TEST_SERVICES}
- COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX}
+ - LOCALSTACK_URL=http://localstack:4566
+ - BLOB_SERVICE_URL=http://blob-server:50051
image: commapp/backup-server:0.1
ports:
- "${COMM_SERVICES_PORT_BACKUP}:50051"
volumes:
- - $HOME/.aws/credentials:/root/.aws/credentials:ro
+ - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro
# blob
blob-server:
depends_on:

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 12:46 PM (21 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2524949
Default Alt Text
D6262.diff (3 KB)

Event Timeline