diff --git a/services/backup/Dockerfile b/services/backup/Dockerfile index 9820c5dc2..4d770a564 100644 --- a/services/backup/Dockerfile +++ b/services/backup/Dockerfile @@ -1,51 +1,39 @@ -FROM commapp/services-base:1.3.2 as builder +FROM rust:1.70-bullseye as builder -ENV PATH=/root/.cargo/bin:$PATH - -# Install Curl -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y curl \ +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential cmake git libgtest-dev libssl-dev zlib1g-dev \ && rm -rf /var/lib/apt/lists/* -# Install Rust -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +WORKDIR /home/root/app/backup -RUN mkdir -p /home/comm/app/backup -WORKDIR /home/comm/app/backup -RUN cargo init --bin +# Install more recent version of protobuf, must be ran as root +COPY scripts/install_protobuf.sh ../../scripts/install_protobuf.sh +RUN ../../scripts/install_protobuf.sh -# Cache build dependencies in a new layer -COPY services/backup/Cargo.toml services/backup/Cargo.lock ./ -COPY services/comm-services-lib ../comm-services-lib -RUN cargo build --release && rm src/*.rs +ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse # Copy actual application sources -COPY services/backup . +COPY services/comm-services-lib ../comm-services-lib +COPY services/backup ./ -# Remove the previously-built binary so that only the application itself is -# rebuilt -RUN rm ./target/release/deps/backup* -RUN cargo build --release +RUN cargo install --locked --path . # Runner stage -FROM commapp/services-base:1.3.2 as runner +FROM debian:bullseye-slim as runner + +# Update dependencies, install ca-certificates which are required for TLS +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Only copy built binary from builder stage +COPY --from=builder /usr/local/cargo/bin/backup /usr/local/bin/backup +WORKDIR /home/comm/app/backup # Create a new user comm and use it to run subsequent commands RUN useradd -m comm USER comm -# Only copy built binary from builder stage -WORKDIR /home/comm/app/backup -COPY --from=builder /home/comm/app/backup/target/release/backup . - -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 +ENV RUST_LOG=info + +CMD ["backup"] diff --git a/services/docker-compose.yml b/services/docker-compose.yml index c952cc910..eed1da273 100644 --- a/services/docker-compose.yml +++ b/services/docker-compose.yml @@ -1,113 +1,111 @@ version: '3.9' volumes: localstack: services: # tunnelbroker tunnelbroker-server: depends_on: - localstack - rabbitmq build: dockerfile: services/tunnelbroker/Dockerfile context: ../ image: commapp/tunnelbroker-server:0.5 ports: - '${COMM_SERVICES_PORT_TUNNELBROKER}:50051' volumes: - $HOME/.aws/config:/home/comm/.aws/config:ro - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro # backup backup-server: + platform: linux/amd64 depends_on: - localstack - blob-server build: dockerfile: services/backup/Dockerfile context: ../ - args: - - COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} - - LOCALSTACK_URL=http://localstack:4566 - - BLOB_SERVICE_URL=http://blob-server:50051 - image: commapp/backup-server:0.1 + image: commapp/backup-server:0.2 ports: - - '${COMM_SERVICES_PORT_BACKUP}:50051' + - '${COMM_SERVICES_PORT_BACKUP}:50052' volumes: + - $HOME/.aws/config:/home/comm/.aws/config:ro - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro # blob blob-server: platform: linux/amd64 depends_on: - localstack build: dockerfile: services/blob/Dockerfile context: ../ args: - COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} image: commapp/blob-server:0.1 ports: - '${COMM_SERVICES_PORT_BLOB}:50053' volumes: - $HOME/.aws/config:/home/comm/.aws/config:ro - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro # identity identity-server: platform: linux/amd64 depends_on: - localstack build: dockerfile: services/identity/Dockerfile context: ../ image: commapp/identity-server:0.1 ports: - '${COMM_SERVICES_PORT_IDENTITY}:50054' # feature-flags feature-flags-server: depends_on: - localstack build: dockerfile: services/feature-flags/Dockerfile context: ../ image: commapp/feature-flags:0.1 ports: - '${COMM_SERVICES_PORT_FEATURE_FLAGS}:50051' volumes: - $HOME/.aws/config:/home/comm/.aws/config:ro - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro # reports reports-server: platform: linux/amd64 depends_on: - localstack - blob-server build: dockerfile: services/reports/Dockerfile context: ../ image: commapp/reports-server:0.1 ports: - '${COMM_SERVICES_PORT_REPORTS}:50056' volumes: - $HOME/.aws/config:/home/comm/.aws/config:ro - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro # localstack localstack: image: localstack/localstack hostname: localstack ports: - '4566:4566' environment: - SERVICES=s3,dynamodb - DATA_DIR=/tmp/localstack - HOSTNAME_EXTERNAL=localstack volumes: - localstack:/tmp/localstack # RabbitMQ rabbitmq: image: rabbitmq:3-management hostname: rabbitmq ports: - '5672:5672' - '5671:5671' - '15672:15672' environment: - RABBITMQ_DEFAULT_USER=comm - RABBITMQ_DEFAULT_PASS=comm