diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..05edd27 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,72 @@ +name: Release Docker image + +on: + push: + branches: [main, dev] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + docker: + strategy: + fail-fast: false + matrix: + arch: [ + # [use-cross, target, platform] + [false, x86_64-unknown-linux-gnu, linux/amd64], + [true, aarch64-unknown-linux-gnu, linux/arm64/v8], + ] + runs-on: ubuntu-latest + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v3 + + - name: Setup Rust toolchain + id: rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.arch[1] }} + override: true + + - name: Setup Rust Cache + id: rust-cache + uses: Swatinem/rust-cache@v2 + + - name: Build + id: rust_build + uses: actions-rs/cargo@v1 + with: + use-cross: ${{ matrix.arch[0] }} + command: build + args: --release --target ${{ matrix.arch[1] }} + + - name: Setup QEMU + id: qemu + uses: docker/setup-qemu-action@v2 + + - name: Setup Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + id: login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build Image and Push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: ${{ matrix.arch[2] }} + cache-to: type=gha,mode=max,ignore-error=true + cache-from: type=gha + push: true + tags: revanced/revanced-discord-bot:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46e1620..b501920 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: - name: Set up cache uses: Swatinem/rust-cache@v2 with: - cache-on-failure: "true" + cache-on-failure: "true" - name: cargo build uses: actions-rs/cargo@v1 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..92fcf06 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM gcr.io/distroless/cc +# Discord info +ARG DISCORD_AUTHORIZATION_TOKEN +ENV DISCORD_AUTHORIZATION_TOKEN $DISCORD_AUTHORIZATION_TOKEN +# MongoDB info +ARG MONGODB_URI +ENV MONGODB_URI $MONGODB_URI +COPY ./target/**/release/revanced-discord-bot / +CMD ["/revanced-discord-bot"] \ No newline at end of file