Skip to content

Commit

Permalink
fix: usage of the images as containers in the GitHub Actions
Browse files Browse the repository at this point in the history
See the comment at the end.
  • Loading branch information
MarkoSagadin committed Oct 24, 2024
1 parent b7a601c commit 41cd87d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ The `ncs-zepyhr` folder contains only a single Dockerfile with two multi-stage b
- `ZSH` - A docker image which inherits from `DEV` stage. It contains ZSH shell and some other tools
for nicer developer experience.

<!-- prettier-ignore -->
> [!WARNING]
> Using the `CI` image to create a container in the GitHub Actions workflow it is mandatory to
> change the default shell to `bash -l {0}` by modifying the `default.run.shell` field. The shell
> must be login shell to source the environment variables correctly, otherwise the installed tools
> inside the image won't be available.
#### Naming scheme

This images adhere to the following naming scheme:
Expand Down
26 changes: 20 additions & 6 deletions ncs-zephyr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ RUN <<EOT
rm ./yq
EOT

# Append environment variables of the toolchain-manager to the user's bashrc to
# get access to the installed programs. See extra info at the end of the file.
# Append environment variables of the toolchain-manager to the user's bashrc
# and /etc/profile to get access to the installed programs. See extra info at
# the end of the file.
RUN nrfutil toolchain-manager env --as-script sh >> ~/.bashrc
RUN nrfutil toolchain-manager env --as-script sh >> /etc/profile

#############
# Dev image #
Expand Down Expand Up @@ -162,9 +164,11 @@ RUN find /home/user/ncs/toolchains/ -path '**/usr/local/bin/*' | \
# Make 'user' default on launch
USER user

# Append environment variables of the toolchain-manager to the user's bashrc to
# get access to the installed programs. See extra info at the end of the file.
# Append environment variables of the toolchain-manager to the user's bashrc
# and and /etc/profile to get access to the installed programs.
# See extra info at the end of the file.
RUN nrfutil toolchain-manager env --as-script sh >> ~/.bashrc
RUN nrfutil toolchain-manager env --as-script sh >> /etc/profile

#############
# ZSH image #
Expand Down Expand Up @@ -239,11 +243,21 @@ EOF
EOT


# Append environment variables of the toolchain-manager to the user's bashrc to
# get access to the installed programs.
# Append environment variables of the toolchain-manager to the user's bashrc
# and and /etc/profile to get access to the installed programs.
#
# Previously that was done with the ENTRYPOINT command, however that is a bit
# error prone for devcontainer usecases, as it isn't always taken into account.
#
# The reason that we need to append to both to some rc file and /etc/profile is
# is that the rc file gets sourced when a interactive shell is started (like
# when you run docker run -it), but /etc/profile is sourced when a non-interactive
# login shell is started. This solves the GitHub Action workflow issue where
# which always runs the command in a non-interactive shell. By setting the
# defaults.run.shell property to "bash -l {0}" the /etc/profile file is sourced,
# thus we get access to the path.
RUN nrfutil toolchain-manager env --as-script sh >> ~/.zshrc
RUN nrfutil toolchain-manager env --as-script sh >> /etc/profile

# Execute the file so that plugins are installed.
RUN zsh ~/.zshrc
Expand Down

0 comments on commit 41cd87d

Please sign in to comment.