Skip to content

Commit

Permalink
Docker build for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Sep 28, 2023
1 parent 3f4493f commit 806894e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
58 changes: 40 additions & 18 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 806894e

Please sign in to comment.