Skip to content

Commit 0337053

Browse files
authored
Merge pull request #1266 from NickeZ/docker-macos-compat
Some changes to docker to make it work on apple m1 / macos
2 parents 11fac8a + b0ca0f4 commit 0337053

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jlink-flash-factory-setup: | build
129129
jlink-flash-firmware-semihosting: | build-semihosting
130130
JLinkExe -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build-semihosting/scripts/firmware.jlink
131131
dockerinit:
132-
./scripts/container.sh build --pull --force-rm --no-cache -t shiftcrypto/firmware_v2 .
132+
./scripts/container.sh build --pull --platform linux/amd64 --force-rm --no-cache -t shiftcrypto/firmware_v2 .
133133
dockerdev:
134134
./scripts/dockerenv.sh
135135
dockerrel:

scripts/dockerenv.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dockerdev () {
4141

4242
if ! $RUNTIME images --filter "reference=${CONTAINER_IMAGE}" | grep -q "${CONTAINER_IMAGE}"; then
4343
echo "No '${CONTAINER_IMAGE}' ${RUNTIME} image found! Maybe you need to run
44-
'${RUNTIME} build --pull -t ${CONTAINER_IMAGE} .'?" >&2
44+
'${RUNTIME} build --platform linux/amd64 --pull -t ${CONTAINER_IMAGE} .'?" >&2
4545
exit 1
4646
fi
4747

@@ -74,8 +74,11 @@ dockerdev () {
7474
# Use same user/group id as on the host, so that files are not created as root in the
7575
# mounted volume. Only needed for Docker. On rootless podman, the host user maps to the
7676
# container root user.
77-
$RUNTIME exec -it "$CONTAINER_NAME" groupadd -o -g "$(id -g)" dockergroup
78-
$RUNTIME exec -it "$CONTAINER_NAME" useradd -u "$(id -u)" -m -g dockergroup dockeruser
77+
# If group already exists, don't create it
78+
if ! $RUNTIME exec -it "$CONTAINER_NAME" getent group "$(id -g)" > /dev/null ; then
79+
$RUNTIME exec -it "$CONTAINER_NAME" groupadd -o -g "$(id -g)" dockergroup
80+
fi
81+
$RUNTIME exec -it "$CONTAINER_NAME" useradd -u "$(id -u)" -m -g "$(id -g)" dockeruser
7982
fi
8083

8184
# Call a second time to enter the container.

0 commit comments

Comments
 (0)