Skip to content

Commit

Permalink
Fix mount permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Sep 22, 2023
1 parent c98c012 commit c4d5f81
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
FROM docker.io/zmkfirmware/zmk-build-arm:stable

RUN apt-get update \
&& apt-get install -y wget \
&& wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq \
&& chmod +x /usr/bin/yq

ARG USER_ID=1000

RUN adduser --disabled-password --gecos '' --uid ${USER_ID} zmk

USER zmk

WORKDIR /app

COPY config/west.yml config/west.yml
Expand All @@ -10,13 +21,4 @@ RUN west update

RUN west zephyr-export

RUN apt-get update \
&& apt-get install -y wget \
&& wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq \
&& chmod +x /usr/bin/yq

COPY build.yaml ./

COPY bin/build.sh ./

CMD ["./build.sh"]
CMD ["bin/build.sh"]
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ DOCKER := $(shell { command -v podman || command -v docker; })
.PHONY: all clean distclean

all:
$(DOCKER) build --tag zmk --file Dockerfile .
$(DOCKER) build --tag zmk --build-arg USER_ID=$(shell id -u) --file Dockerfile .
$(DOCKER) run --rm -it --name zmk \
-v $(PWD)/bin:/app/bin:ro \
-v $(PWD)/build:/app/build \
-v $(PWD)/build.yaml:/app/build.yaml:ro \
-v $(PWD)/config:/app/config:ro \
-v $(PWD)/firmware:/app/firmware \
-e USERID=$(shell id -u) \
zmk

clean:
Expand Down
20 changes: 6 additions & 14 deletions bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/usr/bin/env bash

set -eu

CONFIG_DIR="${CONFIG_DIR:-$(pwd)/config}"
TIMESTAMP="${TIMESTAMP:-$(date -u +"%Y%m%d%H%M%S")}"
BUILD_MATRIX="${BUILD_MATRIX:-build.yaml}"
USERID="${USERID:-$(id -u)}"
config_dir="$(pwd)/config"
timestamp=$(date -u +"%Y%m%d%H%M%S")

while IFS=$',' read -r board shield; do
extra_cmake_args=${shield:+-DSHIELD="$shield"}
Expand All @@ -23,23 +19,19 @@ while IFS=$',' read -r board shield; do

if [[ ! -d "$build_dir" ]]; then
west build -s zmk/app -b "$board" -d ${build_dir} -- \
-DZMK_CONFIG="$CONFIG_DIR" "${extra_cmake_args}"
-DZMK_CONFIG="$config_dir" "${extra_cmake_args}"
else
west build -d ${build_dir} -- -DZMK_CONFIG="$CONFIG_DIR"
west build -d ${build_dir} -- -DZMK_CONFIG="$config_dir"
fi

# # echo -e "${display_name} KConfig\n"
# # grep -v -e "^#" -e "^$" ${build_dir}/zephyr/.config | sort

cp ${build_dir}/zephyr/zmk.uf2 "firmware/${TIMESTAMP}-${artifact_name}.uf2"

chown ${USERID} -R ${build_dir}
cp ${build_dir}/zephyr/zmk.uf2 "firmware/${timestamp}-${artifact_name}.uf2"
done < <(yq '
[{"board": .board[], "shield": .shield[] // ""}] + .include
| filter(.board)
| unique_by(.board + .shield).[]
| [.board, .shield // ""]
| @csv
' ${BUILD_MATRIX_PATH})

chown ${USERID} firmware/*
' build.yaml)

0 comments on commit c4d5f81

Please sign in to comment.