-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_docker_image.sh
More file actions
executable file
·40 lines (35 loc) · 1.09 KB
/
build_docker_image.sh
File metadata and controls
executable file
·40 lines (35 loc) · 1.09 KB
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
38
39
40
#!/usr/bin/env bash
#
# Created on Wed Sep 04 2024 18:04:23
# Author: Mukai (Tom Notch) Yu
# Email: mukaiy@andrew.cmu.edu
# Affiliation: Carnegie Mellon University, Robotics Institute
#
# Copyright Ⓒ 2024 Mukai (Tom Notch) Yu
#
set -euo pipefail
set -a
. "$(dirname "$0")"/variables.sh
set +a
# Determine the local platform
if [[ "$(uname -m)" == "x86_64" ]]; then
LOCAL_PLATFORM="linux/amd64"
elif [[ "$(uname -m)" == "arm64" ]]; then
LOCAL_PLATFORM="linux/arm64"
else
echo "Unsupported local platform: $(uname -m)"
exit 1
fi
# Check if the builder already exists
if ! docker buildx inspect "${BUILDER}" &>/dev/null; then
echo "Creating Docker Buildx builder '${BUILDER}'..."
docker buildx create \
--name "${BUILDER}" \
--use --platform linux/amd64,linux/arm64 \
--driver docker-container
else
echo "Docker Buildx builder '${BUILDER}' already exists."
docker buildx use "${BUILDER}"
fi
# Build the Docker image for only the local platform, push.sh will push multi-platform version
docker buildx bake --file "$(dirname "$0")"/../docker-compose.yml --load --set "*.platform=${LOCAL_PLATFORM}"