Skip to content

Commit

Permalink
docker build
Browse files Browse the repository at this point in the history
ajout du fichier ".dockerignore" : comme pour .git les fichiers listés ici ne sont pas copiés par l'instruction COPY . du Dockerfile
copier "install.sh" dans /root car on l'utilise pendant la séquence d'initialisation "init.sh"
Ajout du "healthcheck": permet de valider la bonne initialisation du container, on peut ainsi le tester dans le workflow
Ne pas re-télécharger le source jeedom durant l'initialisation (init.sh) puisqu'on l'a déjà fait durant le build (Dockerfile).
Fix la fonction "trap" à l'arrêt du conteneur
  • Loading branch information
pifou25 committed Dec 14, 2024
1 parent 87c41f5 commit 9111ba6
Show file tree
Hide file tree
Showing 6 changed files with 538 additions and 2,026 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
/vendor
/docs
14 changes: 10 additions & 4 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,26 @@ jobs:
run: |
docker build -t jeedom:bullseye --build-arg DEBIAN=bullseye --build-arg DATABASE=1 .
- name: run jeedom:bullseye and check
# build current image for bullseye and check it
# run current image for bullseye and check it
run: |
docker run -p 80:80 -d --rm --name jeedom_bullseye jeedom:bullseye
sleep 45
until [ "`docker inspect -f {{.State.Health.Status}} jeedom_bullseye`" == "healthy" ]; do
echo "waiting container to be healthy..."
sleep 5;
done;
docker exec jeedom_bullseye php sick.php
- name: Build jeedom:bookworm
# build current image for bookworm
run: |
docker build -t jeedom:bookworm --build-arg DEBIAN=bookworm --build-arg DATABASE=1 .
- name: run jeedom:bookworm and check
# build current image for bookworm and check it
# run current image for bookworm and check it
run: |
docker run -p 81:80 -d --rm --name jeedom_bookworm jeedom:bookworm
sleep 45
until [ "`docker inspect -f {{.State.Health.Status}} jeedom_bookworm`" == "healthy" ]; do
echo "waiting container to be healthy..."
sleep 5;
done;
docker exec jeedom_bookworm php sick.php
- name: Clean docker image
Expand Down
49 changes: 36 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,53 @@ VOLUME /var/lib/mysql

#speed up build using docker cache
RUN apt update -y
RUN apt -o Dpkg::Options::="--force-confdef" -y install software-properties-common \
RUN apt -o Dpkg::Options::="--force-confdef" -y -q install software-properties-common \
ntp ca-certificates unzip curl sudo cron locate tar telnet wget logrotate dos2unix ntpdate htop \
iotop vim iftop smbclient git python3 python3-pip libexpat1 ssl-cert \
apt-transport-https xvfb cutycapt xauth at mariadb-client espeak net-tools nmap ffmpeg usbutils \
gettext libcurl3-gnutls chromium librsync-dev ssl-cert iputils-ping \
apache2 apache2-utils libexpat1 ssl-cert \
php libapache2-mod-php php-json php-mysql php-curl php-gd php-imap php-xml php-opcache php-soap php-xmlrpc \
php-common php-dev php-zip php-ssh2 php-mbstring php-ldap php-yaml php-snmp && apt -y remove brltty
php-common php-dev php-zip php-ssh2 php-mbstring php-ldap php-yaml php-snmp \
npm && \
# install npm, and node with fixed version
npm install n -g && n 20.18.1 && \
#clean
apt -y remove brltty

COPY install/install.sh /tmp/
RUN sh /tmp/install.sh -s 1 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 2 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 3 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 4 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 5 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
COPY --chown=root:root --chmod=550 install/install.sh /root/
# install step by step : step_1_upgrade ... useless, using the LATEST debian
# RUN sh /root/install.sh -s 1 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_2_mainpackage ... useless, already installed before
# RUN sh /root/install.sh -s 2 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_3_database ... only if $DATABASE
RUN sh /root/install.sh -s 3 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_4_apache
RUN sh /root/install.sh -s 4 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_5_php : install php with extensions
RUN sh /root/install.sh -s 5 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step 6 : copy jeedom source files from local
COPY . ${WEBSERVER_HOME}
RUN sh /tmp/install.sh -s 7 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 8 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 9 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 10 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
RUN sh /tmp/install.sh -s 11 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_7_jeedom_customization_mariadb
RUN sh /root/install.sh -s 7 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_8_jeedom_customization
RUN sh /root/install.sh -s 8 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_9_jeedom_configuration
RUN sh /root/install.sh -s 9 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_10_jeedom_installation : install composer
COPY --from=composer/composer:latest-bin /composer /usr/bin/composer
RUN composer install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader
# RUN sh /root/install.sh -s 10 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
# step_11_jeedom_post
RUN sh /root/install.sh -s 11 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker

RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN echo >${WEBSERVER_HOME}/initialisation

# check if apache is running
HEALTHCHECK --interval=1m --timeout=3s --retries=5 --start-period=10s --start-interval=5s \
CMD curl -f http://localhost/ || exit 1

WORKDIR ${WEBSERVER_HOME}
EXPOSE 80
EXPOSE 443
Expand Down
Loading

0 comments on commit 9111ba6

Please sign in to comment.