Skip to content

Commit

Permalink
Remove the "build" user
Browse files Browse the repository at this point in the history
GitHub Actions disallows the use of USER instruction.

Signed-off-by: Pavel Hübner <pavel.hubner@hardwario.com>
  • Loading branch information
hubpav committed Dec 26, 2022
1 parent fbca845 commit f395335
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
29 changes: 7 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Dockerfile for nRF Connect SDK v2.2.0
FROM ubuntu:22.04

# Add user (and group) "build"
RUN useradd -ms /bin/bash build

# Install "openssh-client" + "unzip" packages
RUN DEBIAN_FRONTEND=noninteractive apt-get -qy update \
&& DEBIAN_FRONTEND=noninteractive apt-get -qy install openssh-client unzip \
Expand All @@ -18,19 +15,10 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get -qy update \
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 \
&& rm -rf /var/lib/apt/lists/*

# Switch to user "build"
USER build

# Set working directory
WORKDIR /home/build

# Create "~/.local/opt" directory
RUN mkdir -m 700 -p ~/.local/opt

# Download GN tool
RUN wget --no-hsts --no-verbose -O gn.zip \
https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest \
&& unzip gn.zip -d ~/.local/opt/gn \
&& unzip gn.zip -d /opt/gn \
&& rm gn.zip

# Set up Zephyr SDK (toolchain)
Expand All @@ -39,9 +27,9 @@ RUN wget --no-hsts --no-verbose \
&& wget --no-hsts --no-verbose -O - \
/~https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.1/sha256.sum \
| shasum --check --ignore-missing \
&& tar xf zephyr-sdk-0.15.1_linux-x86_64.tar.gz -C ~/.local/opt \
&& tar xf zephyr-sdk-0.15.1_linux-x86_64.tar.gz -C /opt \
&& rm zephyr-sdk-0.15.1_linux-x86_64.tar.gz \
&& ~/.local/opt/zephyr-sdk-0.15.1/setup.sh -c -h -t all
&& /opt/zephyr-sdk-0.15.1/setup.sh -c -h -t all

# Install required Python packages
# Source: https://raw.githubusercontent.com/nrfconnect/sdk-nrf/v2.2.0/west.yml
Expand All @@ -52,12 +40,9 @@ RUN pip3 install --user --no-cache-dir --no-warn-script-location -r \
&& pip3 install --user --no-cache-dir --no-warn-script-location -r \
https://raw.githubusercontent.com/nrfconnect/sdk-mcuboot/v1.9.99-ncs3/scripts/requirements.txt

# Create "workspace" directory
RUN mkdir workspace

# Use "workspace" as working directory
WORKDIR /home/build/workspace
# Set working directory
WORKDIR /build

# Set environmental variables
ENV PATH=/home/build/.local/bin:/home/build/.local/opt/gn:$PATH
ENV ZEPHYR_SDK_INSTALL_DIR=/home/build/opt
ENV PATH=/root/.local/bin:/opt/gn:$PATH
ENV ZEPHYR_SDK_INSTALL_DIR=/opt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ docker build -t hardwario/nrf-connect-sdk-build:v2.2.0 .
For more convenient usage, we recommended adding this alias to your shell:

```
alias dwest="docker run --rm -it -v `pwd`:/home/build/workspace hardwario/nrf-connect-sdk-build:v2.2.0 west"
alias dwest="docker run --rm -it -v `pwd`:/build hardwario/nrf-connect-sdk-build:v2.2.0 west"
```

Reload your shell environment and test the functionality:
Expand Down

0 comments on commit f395335

Please sign in to comment.