-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
riotdocker-base: Split out build logic #225
Open
maribu
wants to merge
1
commit into
master
Choose a base branch
from
riotdocker-base/reduce-layers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,36 +3,11 @@ FROM ubuntu:jammy | |
LABEL maintainer="Kaspar Schleiser <[email protected]>" | ||
|
||
RUN \ | ||
echo 'Update the package index files to latest available versions' >&2 && \ | ||
apt-get update && \ | ||
echo 'Install GCC' >&2 && \ | ||
apt-get -y --no-install-recommends install \ | ||
gcc \ | ||
git \ | ||
python3 \ | ||
python3-dev \ | ||
python3-pip \ | ||
&& \ | ||
echo 'Clean up installation files' >&2 && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
--mount=type=bind,source=build.sh,target=/root/build.sh \ | ||
--mount=type=bind,source=run.sh,target=/root/run.sh \ | ||
--mount=type=bind,source=create_user.c,target=/root/create_user.c \ | ||
cd /root && ./build.sh | ||
|
||
# compile suid create_user binary | ||
COPY create_user.c /tmp/create_user.c | ||
RUN gcc -DHOMEDIR=\"/data/riotbuild\" -DUSERNAME=\"riotbuild\" /tmp/create_user.c -o /usr/local/bin/create_user \ | ||
&& chown root:root /usr/local/bin/create_user \ | ||
&& chmod u=rws,g=x,o=- /usr/local/bin/create_user \ | ||
&& rm /tmp/create_user.c | ||
|
||
# Create working directory for mounting the RIOT sources | ||
RUN mkdir -m 777 -p /data/riotbuild | ||
|
||
# Set a global system-wide git user and email address | ||
RUN git config --system user.name "riot" && \ | ||
git config --system user.email "[email protected]" && \ | ||
git config --system --add safe.directory /data/riotbuild | ||
|
||
# Copy our entry point script (signal wrapper) | ||
COPY run.sh /run.sh | ||
ENTRYPOINT ["/bin/bash", "/run.sh"] | ||
|
||
# By default, run a shell when no command is specified on the docker command line | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/bash | ||
|
||
# Automatically exit on error | ||
set -e | ||
|
||
COUNTER_STEP=0 | ||
COUNTER_SUBSTEP=0 | ||
BLUE="\e[34m" | ||
BOLD="\e[1m" | ||
NORMAL="\e[0m" | ||
|
||
step() { | ||
COUNTER_SUBSTEP=0 | ||
COUNTER_STEP=$(("$COUNTER_STEP" + 1)) | ||
printf "${BLUE}${BOLD}==>${NORMAL}${BOLD} Step %d:${NORMAL} %s\n" "$COUNTER_STEP" "$1" | ||
} | ||
|
||
substep() { | ||
COUNTER_SUBSTEP=$(("$COUNTER_SUBSTEP" + 1)) | ||
printf "${BLUE}${BOLD} -->${NORMAL}${BOLD} Step %d.%d:${NORMAL} %s\n" \ | ||
"$COUNTER_STEP" "$COUNTER_SUBSTEP" "$1" | ||
} | ||
|
||
step_install_dev_tools() { | ||
step "Installing development tools" | ||
|
||
substep "Updating package index" | ||
apt-get update | ||
|
||
substep "Installing GCC" | ||
apt-get -y --no-install-recommends install gcc | ||
|
||
substep "Installing git" | ||
apt-get -y --no-install-recommends install git | ||
|
||
substep "Installing Python" | ||
apt-get -y --no-install-recommends install \ | ||
python3 \ | ||
python3-dev \ | ||
python3-pip | ||
|
||
substep "Clean up installation files" | ||
apt-get clean | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
} | ||
|
||
step_provide_create_user_cmd() { | ||
step "Providing create_user binary" | ||
|
||
substep "Compiling create_user from source" | ||
gcc -DHOMEDIR=\"/data/riotbuild\" -DUSERNAME=\"riotbuild\" create_user.c -o /usr/local/bin/create_user | ||
|
||
substep "Updating file attributes of create_user" | ||
chown root:root /usr/local/bin/create_user | ||
chmod u=rws,g=x,o=- /usr/local/bin/create_user | ||
} | ||
|
||
step_setup_dirs() { | ||
step "Setting up folders and files" | ||
|
||
substep "Creating /data/riotbuild" | ||
mkdir -m 777 -p /data/riotbuild | ||
|
||
substep "Creating /run.sh" | ||
cp run.sh /run.sh | ||
} | ||
|
||
step_setup_git() { | ||
step "Setting up git" | ||
|
||
substep "Configuring user and email" | ||
git config --system user.name "riot" | ||
git config --system user.email "[email protected]" | ||
|
||
substep "Setting up safe directories" | ||
git config --system --add safe.directory /data/riotbuild | ||
} | ||
|
||
step_install_dev_tools | ||
step_provide_create_user_cmd | ||
step_setup_dirs | ||
step_setup_git | ||
exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing multiple apt-get install in separate steps incurs some run-time cost from hooks being run after each apt-get.
But fine with me -- it's little time spent in CI, and much better readability gained.