diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 329003a..71eb0d7 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -13,25 +13,40 @@ 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/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