diff --git a/.dockerignore b/.dockerignore index 7d9b3c6d6..7614ca4c2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,43 +1,44 @@ .dockerignore .DS_Store .git .eslintcache .vscode !.vscode/extensions.json node_modules desktop/node_modules desktop/assets desktop/dist desktop/out desktop/*.provisionprofile landing/node_modules landing/dist lib/node_modules native !native/package.json !native/.flowconfig !native/ios/Podfile !native/expo-modules/comm-expo-package/package.json web/node_modules web/dist keyserver/dist keyserver/node_modules keyserver/facts keyserver/secrets keyserver/*.env keyserver/*.env.* keyserver/addons/rust-node-addon/target services/*/Dockerfile 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 index c53f77318..4fa67503f 100644 --- a/services/.env +++ b/services/.env @@ -1,5 +1,6 @@ COMM_SERVICES_PORT_TUNNELBROKER=50051 COMM_SERVICES_PORT_BACKUP=50052 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 index 45a5b655f..c952cc910 100644 --- a/services/docker-compose.yml +++ b/services/docker-compose.yml @@ -1,97 +1,113 @@ 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: 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 ports: - '${COMM_SERVICES_PORT_BACKUP}:50051' volumes: - $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 diff --git a/services/reports/Dockerfile b/services/reports/Dockerfile new file mode 100644 index 000000000..5e439e503 --- /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"]