Skip to content

Commit f5225b4

Browse files
authored
Docker amd64 and arm64 build (#59)
1 parent d6ea12a commit f5225b4

File tree

7 files changed

+147
-33
lines changed

7 files changed

+147
-33
lines changed

.dockerignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ README.md
77
!target/x86_64-unknown-linux-gnu/debug/cloud-server-oss
88
!target/x86_64-unknown-linux-gnu/release/golem-shard-manager
99
!target/x86_64-unknown-linux-gnu/release/worker-executor-oss
10-
!target/x86_64-unknown-linux-gnu/release/cloud-server-oss
10+
!target/x86_64-unknown-linux-gnu/release/cloud-server-oss
11+
!target/aarch64-unknown-linux-gnu/debug/golem-shard-manager
12+
!target/aarch64-unknown-linux-gnu/debug/worker-executor-oss
13+
!target/aarch64-unknown-linux-gnu/debug/cloud-server-oss
14+
!target/aarch64-unknown-linux-gnu/release/golem-shard-manager
15+
!target/aarch64-unknown-linux-gnu/release/worker-executor-oss
16+
!target/aarch64-unknown-linux-gnu/release/cloud-server-oss

.github/workflows/ci.yaml

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@ jobs:
2929
with:
3030
toolchain: stable
3131
override: true
32+
- name: Install Rust Targets
33+
run: |
34+
rustup target add x86_64-unknown-linux-gnu
35+
rustup target add aarch64-unknown-linux-gnu
3236
- name: Install Protoc
3337
uses: arduino/setup-protoc@v1
3438
with:
3539
repo-token: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Install gcc-aarch64-linux-gnu
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install gcc-aarch64-linux-gnu
3644
- uses: actions/cache@v3
3745
with:
3846
path: |
@@ -42,11 +50,17 @@ jobs:
4250
~/.cargo/git/db/
4351
target/
4452
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
45-
- name: Install Target
46-
run: rustup target add x86_64-unknown-linux-gnu
47-
- name: Build Executables
48-
run: cargo build --release --target ${{ env.BUILD_TARGET }}
49-
- name: Set version
53+
- name: Build amd64 Executables
54+
run: |
55+
cargo build --release --target x86_64-unknown-linux-gnu
56+
- name: Build arm64 Executables
57+
run: |
58+
cargo build --release --target aarch64-unknown-linux-gnu --config "target.aarch64-unknown-linux-gnu.linker = 'aarch64-linux-gnu-gcc'"
59+
- name: Set up QEMU
60+
uses: docker/setup-qemu-action@v3
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
- name: Set Docker version
5064
id: set-version
5165
run: |
5266
if [ "${{ github.event_name }}" == 'push' ] && [ "${{ github.ref_type }}" == 'tag' ]; then
@@ -56,60 +70,55 @@ jobs:
5670
COMMIT_SHORT_HASH=$(git rev-parse --short=7 HEAD)
5771
echo "DOCKER_VERSION=${COMMIT_SHORT_HASH}" >> $GITHUB_ENV
5872
fi
59-
- uses: satackey/action-docker-layer-caching@v0.0.11
73+
- uses: jpribyl/action-docker-layer-caching@v0.1.1
6074
continue-on-error: true
61-
6275
- name: Log in to Docker Hub
63-
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
76+
uses: docker/login-action@v3
6477
with:
6578
username: ${{ secrets.DOCKERHUB_USERNAME }}
6679
password: ${{ secrets.DOCKERHUB_PASSWORD }}
67-
6880
- name: Extract metadata (tags, labels) for worker executor
6981
id: meta-worker-executor
70-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
82+
uses: docker/metadata-action@v5
7183
with:
7284
images: golemservices/golem-worker-executor
73-
7485
- name: Build and push worker executor image
75-
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
86+
uses: docker/build-push-action@v5
7687
with:
7788
context: .
78-
file: ./golem-worker-executor-oss/docker/amd64/Dockerfile
89+
file: ./golem-worker-executor-oss/docker/Dockerfile
7990
push: true
91+
platforms: linux/amd64,linux/arm64
8092
tags: ${{ steps.meta-worker-executor.outputs.tags }}
8193
labels: ${{ steps.meta-worker-executor.outputs.labels }}
82-
8394
- name: Extract metadata (tags, labels) for shard manager
8495
id: meta-shard-manager
85-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
96+
uses: docker/metadata-action@v5
8697
with:
8798
images: golemservices/golem-shard-manager
88-
8999
- name: Build and push shard manager image
90-
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
100+
uses: docker/build-push-action@v5
91101
with:
92102
context: .
93-
file: ./golem-shard-manager/docker/amd64/Dockerfile
103+
file: ./golem-shard-manager/docker/Dockerfile
94104
push: true
105+
platforms: linux/amd64,linux/arm64
95106
tags: ${{ steps.meta-shard-manager.outputs.tags }}
96107
labels: ${{ steps.meta-shard-manager.outputs.labels }}
97-
98108
- name: Extract metadata (tags, labels) for golem server
99109
id: meta-golem-server
100-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
110+
uses: docker/metadata-action@v5
101111
with:
102112
images: golemservices/golem-server
103-
104113
- name: Build and push cloud server image
105-
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
114+
uses: docker/build-push-action@v5
106115
with:
107116
context: .
108-
file: ./golem-cloud-server-oss/docker/amd64/Dockerfile
117+
file: ./golem-cloud-server-oss/docker/Dockerfile
109118
push: true
119+
platforms: linux/amd64,linux/arm64
110120
tags: ${{ steps.meta-golem-server.outputs.tags }}
111121
labels: ${{ steps.meta-golem-server.outputs.labels }}
112-
113122
build:
114123
runs-on: ubuntu-latest
115124
steps:

CONTRIBUTING.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
## Local Testing
32

4-
To spin up services using the latest code
3+
To spin up services using the latest code
54

65
```bash
76
# Clone golem-services
87
cd golem-services
98
# Find more info below if you are having issues running this command(example: Running from MAC may fail)
10-
# Target has to be x86_64-unknown-linux-gnu
9+
# Target has to be x86_64-unknown-linux-gnu or aarch64-unknown-linux-gnu-gcc
1110
cargo build --release --target x86_64-unknown-linux-gnu
1211

1312
docker-compose up --build
@@ -33,9 +32,11 @@ Make sure to do `docker-compose pull` next time to make sure you are pulling the
3332
### Cargo Build
3433

3534
### MAC
36-
If you are running ` cargo build --target x86_64-unknown-linux-gnu` (cross compiling to Linux) from MAC, you may encounter
35+
If you are running ` cargo build --target ARCH-unknown-linux-gnu` (cross compiling to Linux) from MAC, you may encounter
3736
some missing dependencies. If interested, refer, https://github.com/messense/homebrew-macos-cross-toolchains
3837

38+
### Intel MAC
39+
3940
Typically, the following should allow you to run it successfully.
4041

4142
```bash
@@ -54,6 +55,26 @@ rustup target add x86_64-unknown-linux-gnu
5455
cargo build --target x86_64-unknown-linux-gnu
5556
```
5657

58+
### ARM MAC
59+
60+
Typically, the following should allow you to run it successfully.
61+
62+
```bash
63+
brew tap messense/macos-cross-toolchains
64+
brew install aarch64-unknown-linux-gnu
65+
export CC_AARCH64_UNKNOWN_LINUX_GNU=aarch64-unknown-linux-gnu-gcc
66+
export CXX_AARCH64_UNKNOWN_LINUX_GNU=aarch64-unknown-linux-gnu-g++
67+
export AR_AARCH64_UNKNOWN_LINUX_GNU=aarch64-unknown-linux-gnu-ar
68+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-unknown-linux-gnu-gcc
69+
```
70+
71+
From the root of the project
72+
73+
```bash
74+
rustup target add aarch64-unknown-linux-gnu-gcc
75+
cargo build --target aarch64-unknown-linux-gnu-gcc
76+
```
77+
5778
### LINUX
5879

5980
From the root of the project
@@ -66,4 +87,4 @@ cargo build --target x86_64-unknown-linux-gnu
6687
### WINDOWS
6788
TBD
6889

69-
We will be trying cargo chef and offload cargo build to docker context without impacting the build time.
90+
We will be trying cargo chef and offload cargo build to docker context without impacting the build time.

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
golem-shard-manager:
1212
build:
1313
context: .
14-
dockerfile: golem-shard-manager/docker/amd64/Dockerfile
14+
dockerfile: golem-shard-manager/docker/Dockerfile
1515
environment:
1616
- WASMTIME_BACKTRACE_DETAILS=1
1717
- RUST_BACKTRACE=1
@@ -27,7 +27,7 @@ services:
2727
golem-cloud-server-oss:
2828
build:
2929
context: .
30-
dockerfile: golem-cloud-server-oss/docker/amd64/Dockerfile
30+
dockerfile: golem-cloud-server-oss/docker/Dockerfile
3131
environment:
3232
- ENVIRONMENT=local
3333
- RUST_LOG="debug,h2=warn,hyper=warn,tower=warn"
@@ -52,7 +52,7 @@ services:
5252
golem-worker-executor-oss:
5353
build:
5454
context: .
55-
dockerfile: golem-worker-executor-oss/docker/amd64/Dockerfile
55+
dockerfile: golem-worker-executor-oss/docker/Dockerfile
5656
environment:
5757
- ENVIRONMENT=local
5858
- RUST_LOG=info
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM debian:bookworm-slim as base
2+
3+
ARG TARGETARCH
4+
5+
FROM base AS platform-amd64
6+
7+
ENV RUST_TARGET=x86_64-unknown-linux-gnu
8+
9+
FROM base AS platform-arm64
10+
11+
ENV RUST_TARGET=aarch64-unknown-linux-gnu
12+
13+
FROM platform-${TARGETARCH} AS final
14+
15+
WORKDIR /app
16+
COPY /target/$RUST_TARGET/release/cloud-server-oss ./
17+
COPY /golem-cloud-server-oss/config/cloud-server.toml ./config/cloud-server.toml
18+
19+
RUN apt-get update && apt-get install -y libssl-dev
20+
RUN apt-get update && apt-get install -y ca-certificates
21+
RUN update-ca-certificates
22+
23+
EXPOSE 8080
24+
EXPOSE 9090
25+
26+
ENTRYPOINT ["./cloud-server-oss"]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM debian:bookworm-slim as base
2+
3+
ARG TARGETARCH
4+
5+
FROM base AS platform-amd64
6+
7+
ENV RUST_TARGET=x86_64-unknown-linux-gnu
8+
9+
FROM base AS platform-arm64
10+
11+
ENV RUST_TARGET=aarch64-unknown-linux-gnu
12+
13+
FROM platform-${TARGETARCH} AS final
14+
15+
WORKDIR /app
16+
COPY /target/$RUST_TARGET/release/golem-shard-manager ./
17+
COPY /golem-shard-manager/config/shard-manager.toml ./config/shard-manager.toml
18+
19+
RUN apt-get update && apt-get install -y libssl-dev
20+
RUN apt-get update && apt-get install -y ca-certificates
21+
RUN update-ca-certificates
22+
23+
EXPOSE 8081
24+
EXPOSE 9001
25+
26+
ENTRYPOINT ["./golem-shard-manager"]
27+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM debian:bookworm-slim as base
2+
3+
ARG TARGETARCH
4+
5+
FROM base AS platform-amd64
6+
7+
ENV RUST_TARGET=x86_64-unknown-linux-gnu
8+
9+
FROM base AS platform-arm64
10+
11+
ENV RUST_TARGET=aarch64-unknown-linux-gnu
12+
13+
FROM platform-${TARGETARCH} AS final
14+
15+
WORKDIR /app
16+
COPY /target/$RUST_TARGET/release/worker-executor-oss ./
17+
COPY /golem-worker-executor-oss/config/worker-executor.toml ./config/worker-executor.toml
18+
19+
RUN apt-get update && apt-get install -y libssl-dev
20+
RUN apt-get update && apt-get install -y ca-certificates
21+
RUN update-ca-certificates
22+
23+
EXPOSE 9000
24+
25+
ENTRYPOINT ["./worker-executor-oss"]

0 commit comments

Comments
 (0)