diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 329003a..d0481a2 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -1,37 +1,59 @@ name: CICD on: + workflow_dispatch: push: branches: - master + tags: [ "*" ] + release: + types: [ published ] env: IMAGE: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]') + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: build: name: Build Docker Images runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: - - name: Checkout master - uses: actions/checkout@v1 - - name: Set environment variables - run: | - echo "IMAGE=$(echo ${{env.IMAGE}} )" >> $GITHUB_ENV - - name: Log in to GitHub Packages - run: echo ${PERSONAL_ACCESS_TOKEN} | docker login ghcr.io -u ${{ secrets.NAMESPACE }} --password-stdin - env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - - name: Pull images - run: | - docker pull ${{ env.IMAGE }} || true - - name: Build images - run: | - DOCKER_BUILDKIT=1 docker build -f Dockerfile -t ${{ env.IMAGE }}:latest . - - name: Push images - run: | - docker push ${{ env.IMAGE }}:latest + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: mutinywallet + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + deploy: name: Deploy to Linode runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index ea6e1a1..7021bef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,5 +32,8 @@ bytes = { version = "1.3.0", optional = true } bitcoin_hashes = { version = "0.11", default-features = true, optional = true } futures = { version = "0.3.28", optional = true } +# explict dep due to nightly - https://github.com/rust-lang/rust/issues/113152 +proc-macro2 = "1.0.64" + [features] server = ["axum", "headers", "tokio", "tower-http", "tracing", "tracing-subscriber", "bytes", "bitcoin_hashes", "futures"] diff --git a/Dockerfile b/Dockerfile index 45a654a..0713741 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,11 @@ RUN USER=root cargo new app WORKDIR /usr/src/app RUN mkdir ln-websocket-proxy COPY Cargo.toml Cargo.lock ./ + +# cargo under QEMU building for ARM can consumes 10s of GBs of RAM... +# Solution: https://users.rust-lang.org/t/cargo-uses-too-much-memory-being-run-in-qemu/76531/2 +ENV CARGO_NET_GIT_FETCH_WITH_CLI true + # Needs at least a main.rs file with a main function # Since this is a rust workspace, we need to init the other things too RUN mkdir src && echo "fn main(){}" > src/main.rs && echo "fn main(){}" > src/lib.rs