From 75ab42ecb5d1fd658fc90462f60853162cfeb126 Mon Sep 17 00:00:00 2001 From: Katalina Okano Date: Sun, 20 Nov 2022 22:19:55 -0500 Subject: [PATCH] docker stuff --- .dockerignore | 3 +++ .github/workflows/ci.yaml | 29 +++++++++++++++++++++++++++++ Dockerfile | 17 +++++++++++++++++ README.md | 4 ++-- services/websocket/src/main.rs | 8 ++------ 5 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/ci.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5fcd762 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +target +Dockerfile +.git \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..d30d012 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,29 @@ +name: "CI" + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + service: ["api", "tasks", "websocket"] + steps: + - uses: actions/checkout@v2 + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - run: | + docker build . \ + --build-arg SERVICE=${{ matrix.service }} \ + -t ghcr.io/${{ github.repository }}/${{ matrix.service }}:${{ github.sha }} + - run: | + docker tag ghcr.io/${{ github.repository }}/${{ matrix.service }}:${{ github.sha }} \ + ghcr.io/${{ github.repository }}/${{ matrix.service }}:latest + if: github.ref == 'refs/heads/main' + - run: | + docker push ghcr.io/${{ github.repository }}/${{ matrix.service }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2012886 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM rust:1.65.0-alpine AS builder +ARG SERVICE + +WORKDIR /app +COPY Cargo.toml Cargo.lock ./ +COPY services ./services + +RUN cargo build --bin ${SERVICE} --release + + +FROM alpine AS target +ARG SERVICE + +COPY --from=builder /app/target/release/${SERVICE} /app + +RUN chmod a+x /app +CMD /app diff --git a/README.md b/README.md index 730ab5f..08f2215 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ This API only supports GET, and supports CORS. ## Architecture - Websocket processors - - One pair per PC, PS4US, PS4EU - - Each pair connects to either Census Websocket or NS Websocket, depending on availability. + - One per PC, PS4US, PS4EU + - Connects to [wss://push.nanite-systems.net](https://nanite-systems.net), one process per "environment" - API - Serves https://saerro.harasse.rs - Redis diff --git a/services/websocket/src/main.rs b/services/websocket/src/main.rs index 814ce47..5cf1c31 100644 --- a/services/websocket/src/main.rs +++ b/services/websocket/src/main.rs @@ -110,12 +110,8 @@ async fn main() { let init = tokio::spawn(send_init(tx.clone())); futures::select! { - _ = fused_reader => { - println!("Reader finished"); - } - _ = fused_writer => { - println!("Writer finished"); - } + _ = fused_reader => {} + _ = fused_writer => {} } init.await.unwrap();