summaryrefslogtreecommitdiff
path: root/.gitlab/setup-buildx-remote-builders.sh
blob: 29d50dde86f244954507fc61d7026648db7703c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
set -eux

# --------------------------------------------------------------------- #
#                                                                       #
#  Configures docker buildx to use a remote server for arm building.    #
#  Expects $SSH_PRIVATE_KEY to be a valid ssh ed25519 private key with  #
#  access to the server $ARM_SERVER_USER@$ARM_SERVER_IP                 # 
#                                                                       #
#  This is expected to only be used in the official CI/CD pipeline!     #
#                                                                       #
#  Requirements: openssh-client, docker buildx                          #
#  Inspired by:  https://depot.dev/blog/building-arm-containers         #
#                                                                       #
# --------------------------------------------------------------------- #

cat "$BUILD_SERVER_SSH_PRIVATE_KEY" | ssh-add -

# Test server connections:
ssh "$ARM_SERVER_USER@$ARM_SERVER_IP" "uname -a"
ssh "$AMD_SERVER_USER@$AMD_SERVER_IP" "uname -a"

# Connect remote arm64 server for all arm builds:
docker buildx create \
    --name "multi" \
    --driver "docker-container" \
    --platform "linux/arm64,linux/arm/v7" \
    "ssh://$ARM_SERVER_USER@$ARM_SERVER_IP"

# Connect remote amd64 server for adm64 builds:
docker buildx create --append \
    --name "multi" \
    --driver "docker-container" \
    --platform "linux/amd64" \
    "ssh://$AMD_SERVER_USER@$AMD_SERVER_IP"

docker buildx use multi