diff --git a/.dockerignore b/.dockerignore --- a/.dockerignore +++ b/.dockerignore @@ -39,5 +39,6 @@ services/*/target services/identity/secrets services/electron-update-server/node_modules +services/reports/email-config.json native/cpp/**/build diff --git a/services/.env b/services/.env --- a/services/.env +++ b/services/.env @@ -3,3 +3,4 @@ COMM_SERVICES_PORT_BLOB=50053 COMM_SERVICES_PORT_IDENTITY=50054 COMM_SERVICES_PORT_FEATURE_FLAGS=50055 +COMM_SERVICES_PORT_REPORTS=50056 diff --git a/services/docker-compose.yml b/services/docker-compose.yml --- a/services/docker-compose.yml +++ b/services/docker-compose.yml @@ -35,6 +35,7 @@ - $HOME/.aws/credentials:/home/comm/.aws/credentials:ro # blob blob-server: + platform: linux/amd64 depends_on: - localstack build: @@ -72,6 +73,20 @@ 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 + 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 diff --git a/services/reports/Dockerfile b/services/reports/Dockerfile new file mode 100644 --- /dev/null +++ b/services/reports/Dockerfile @@ -0,0 +1,39 @@ +FROM rust:1.70-bullseye as builder + +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/* + +WORKDIR /home/root/app/reports + +# 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 + +ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse + +# Copy actual application sources +COPY services/comm-services-lib ../comm-services-lib +COPY services/reports ./ + +RUN cargo install --locked --path . + +# Runner stage +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/reports /usr/local/bin/reports +WORKDIR /home/comm/app/reports + +# Create a new user comm and use it to run subsequent commands +RUN useradd -m comm +USER comm + +ENV RUST_LOG=info + +CMD ["reports"]