Skip to content

Commit

Permalink
Performance optimization for container
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller committed Oct 12, 2023
1 parent e812b89 commit c10a857
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 44 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker_bullseye_altuser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
options: --platform linux/arm/v7
name: run_installation_tests.sh
args: |
/code/scripts/installscripts/tests/run_installation_tests.sh
run_installation_tests.sh
- name: Run run_installation_tests2.sh Bullseye ARMv7
uses: tj-actions/docker-run@v2
Expand All @@ -59,7 +59,7 @@ jobs:
options: --platform linux/arm/v7
name: run_installation_tests2.sh
args: |
/code/scripts/installscripts/tests/run_installation_tests2.sh
run_installation_tests2.sh
- name: Run run_installation_tests3.sh Bullseye ARMv7
uses: tj-actions/docker-run@v2
Expand All @@ -68,4 +68,4 @@ jobs:
options: --platform linux/arm/v7
name: run_installation_tests3.sh
args: |
/code/scripts/installscripts/tests/run_installation_tests3.sh
run_installation_tests3.sh
80 changes: 45 additions & 35 deletions ci/Dockerfile.bullseye.test_install.armv7
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
FROM --platform=linux/arm/v7 arm32v7/debian:bullseye-slim
ARG USER_NAME=pi
ARG USER_GROUP=$USER_NAME
ARG GIT_BRANCH
ARG GIT_URL

# Define constants
ENV DOCKER_RUNNING=true
ENV USER=$USER_NAME
ENV GIT_BRANCH=$GIT_BRANCH
ENV GIT_URL=$GIT_URL
ENV DEBIAN_FRONTEND=noninteractive

RUN touch /boot/cmdlinetxt

COPY . /code
WORKDIR /code

RUN groupadd --gid 1000 $USER_GROUP ;\
useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER ;\
chown -R 1000:1000 /code /home/$USER ;\
chmod +x /code/scripts/installscripts/buster-install-default.sh ;\
chmod +x /code/scripts/installscripts/tests/run_installation_tests.sh ;\
chmod +x /code/scripts/installscripts/tests/run_installation_tests2.sh ;\
chmod +x /code/scripts/installscripts/tests/run_installation_tests3.sh

RUN export DEBIAN_FRONTEND=noninteractive ;\
apt-get update ;\
apt-get -y install curl gnupg sudo nano systemd apt-utils ;\
echo 'deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi' > /etc/apt/sources.list.d/raspi.list ;\
# Install all packages
RUN echo 'deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi' > /etc/apt/sources.list.d/raspi.list ;\
echo 'deb http://archive.raspberrypi.org/debian/ bullseye main' >> /etc/apt/sources.list.d/raspi.list ;\
curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\
curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\
echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER ;\
apt-get clean ;\
rm -rf /var/cache/apt/* /var/lib/apt/lists/*

RUN export DEBIAN_FRONTEND=noninteractive ;\
apt-get update ;\
# install here to speed up GitHub Action
apt-get -y install raspberrypi-kernel-headers ;\
apt-get -y dist-upgrade --auto-remove --purge ;\
apt-get -y install wget build-essential git iw locales wpasupplicant ;\
apt-get clean ;\
touch /boot/cmdlinetxt ;\
rm -rf /var/cache/apt/* /var/lib/apt/lists/*
apt-get update && \
apt-get -y install \
apt-utils \
build-essential \
curl \
git \
gnupg \
iw \
locales \
nano \
# install here to speed up GitHub Action
raspberrypi-kernel-headers \
sudo \
systemd \
wget \
wpasupplicant && \
apt-get -y dist-upgrade --auto-remove --purge && \
rm -rf /var/lib/apt/lists/*

# Define user info that my change. Therefore after package installation
ARG USER_NAME=pi
ARG USER_GROUP=$USER_NAME
ENV USER=$USER_NAME

RUN groupadd --gid 1000 $USER_GROUP && \
useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER && \
echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER

# Define need files for installation test
COPY --chown=1000:1000 --chmod=+x scripts/installscripts/tests/run_installation_tests*.sh /test/
COPY --chown=1000:1000 --chmod=+x scripts/installscripts/buster-install-default.sh /

WORKDIR /test

# Define Git Repo variables which frequently change
ARG GIT_BRANCH
ARG GIT_URL
ENV GIT_BRANCH=$GIT_BRANCH
ENV GIT_URL=$GIT_URL

USER $USER
4 changes: 2 additions & 2 deletions scripts/installscripts/tests/run_installation_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export DEBIAN_FRONTEND=noninteractive
# n no RFID registration
# n No reboot

bash ./scripts/installscripts/buster-install-default.sh <<< $'y\nn\n\ny\n\nn\n\ny\n\ny\n\ny\n\ny\nn\nn\n'
bash ./../buster-install-default.sh <<< $'y\nn\n\ny\n\nn\n\ny\n\ny\n\ny\n\ny\nn\nn\n'
INSTALLATION_EXITCODE=$?

# Test installation
./scripts/installscripts/tests/test_installation.sh $INSTALLATION_EXITCODE
./test_installation.sh $INSTALLATION_EXITCODE
4 changes: 2 additions & 2 deletions scripts/installscripts/tests/run_installation_tests2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export DEBIAN_FRONTEND=noninteractive
# yes, reader is connected
# n No reboot

bash ./scripts/installscripts/buster-install-default.sh <<< $'y\nn\n\ny\n\nn\n\ny\n\ny\n\ny\n\ny\ny\n2\ny\nn\n'
bash ./../buster-install-default.sh <<< $'y\nn\n\ny\n\nn\n\ny\n\ny\n\ny\n\ny\ny\n2\ny\nn\n'
INSTALLATION_EXITCODE=$?

# Test installation
./scripts/installscripts/tests/test_installation.sh $INSTALLATION_EXITCODE
./test_installation.sh $INSTALLATION_EXITCODE
4 changes: 2 additions & 2 deletions scripts/installscripts/tests/run_installation_tests3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export DEBIAN_FRONTEND=noninteractive
# n no RFID registration
# n No reboot

bash ./scripts/installscripts/buster-install-default.sh <<< $'y\nn\n\ny\n\ny\nmyuser\nmypassword\nmyclient_id\nmyclient_secret\n\ny\n\ny\n\ny\n\ny\nn\nn\n'
bash ./../buster-install-default.sh <<< $'y\nn\n\ny\n\ny\nmyuser\nmypassword\nmyclient_id\nmyclient_secret\n\ny\n\ny\n\ny\n\ny\nn\nn\n'
INSTALLATION_EXITCODE=$?

# Test installation
./scripts/installscripts/tests/test_installation.sh $INSTALLATION_EXITCODE
./test_installation.sh $INSTALLATION_EXITCODE

0 comments on commit c10a857

Please sign in to comment.