Skip to content

Commit 9111ba6

Browse files
committed
docker build
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
1 parent 87c41f5 commit 9111ba6

File tree

6 files changed

+538
-2026
lines changed

6 files changed

+538
-2026
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
/vendor
3+
/docs

.github/workflows/docker-test.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,26 @@ jobs:
3030
run: |
3131
docker build -t jeedom:bullseye --build-arg DEBIAN=bullseye --build-arg DATABASE=1 .
3232
- name: run jeedom:bullseye and check
33-
# build current image for bullseye and check it
33+
# run current image for bullseye and check it
3434
run: |
3535
docker run -p 80:80 -d --rm --name jeedom_bullseye jeedom:bullseye
36-
sleep 45
36+
until [ "`docker inspect -f {{.State.Health.Status}} jeedom_bullseye`" == "healthy" ]; do
37+
echo "waiting container to be healthy..."
38+
sleep 5;
39+
done;
3740
docker exec jeedom_bullseye php sick.php
3841
- name: Build jeedom:bookworm
3942
# build current image for bookworm
4043
run: |
4144
docker build -t jeedom:bookworm --build-arg DEBIAN=bookworm --build-arg DATABASE=1 .
4245
- name: run jeedom:bookworm and check
43-
# build current image for bookworm and check it
46+
# run current image for bookworm and check it
4447
run: |
4548
docker run -p 81:80 -d --rm --name jeedom_bookworm jeedom:bookworm
46-
sleep 45
49+
until [ "`docker inspect -f {{.State.Health.Status}} jeedom_bookworm`" == "healthy" ]; do
50+
echo "waiting container to be healthy..."
51+
sleep 5;
52+
done;
4753
docker exec jeedom_bookworm php sick.php
4854
4955
- name: Clean docker image

Dockerfile

+36-13
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,53 @@ VOLUME /var/lib/mysql
3535

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

47-
COPY install/install.sh /tmp/
48-
RUN sh /tmp/install.sh -s 1 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
49-
RUN sh /tmp/install.sh -s 2 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
50-
RUN sh /tmp/install.sh -s 3 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
51-
RUN sh /tmp/install.sh -s 4 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
52-
RUN sh /tmp/install.sh -s 5 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
52+
COPY --chown=root:root --chmod=550 install/install.sh /root/
53+
# install step by step : step_1_upgrade ... useless, using the LATEST debian
54+
# RUN sh /root/install.sh -s 1 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
55+
# step_2_mainpackage ... useless, already installed before
56+
# RUN sh /root/install.sh -s 2 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
57+
# step_3_database ... only if $DATABASE
58+
RUN sh /root/install.sh -s 3 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
59+
# step_4_apache
60+
RUN sh /root/install.sh -s 4 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
61+
# step_5_php : install php with extensions
62+
RUN sh /root/install.sh -s 5 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
63+
# step 6 : copy jeedom source files from local
5364
COPY . ${WEBSERVER_HOME}
54-
RUN sh /tmp/install.sh -s 7 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
55-
RUN sh /tmp/install.sh -s 8 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
56-
RUN sh /tmp/install.sh -s 9 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
57-
RUN sh /tmp/install.sh -s 10 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
58-
RUN sh /tmp/install.sh -s 11 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
65+
# step_7_jeedom_customization_mariadb
66+
RUN sh /root/install.sh -s 7 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
67+
# step_8_jeedom_customization
68+
RUN sh /root/install.sh -s 8 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
69+
# step_9_jeedom_configuration
70+
RUN sh /root/install.sh -s 9 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
71+
# step_10_jeedom_installation : install composer
72+
COPY --from=composer/composer:latest-bin /composer /usr/bin/composer
73+
RUN composer install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader
74+
# RUN sh /root/install.sh -s 10 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
75+
# step_11_jeedom_post
76+
RUN sh /root/install.sh -s 11 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker
77+
5978
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
6079
RUN echo >${WEBSERVER_HOME}/initialisation
6180

81+
# check if apache is running
82+
HEALTHCHECK --interval=1m --timeout=3s --retries=5 --start-period=10s --start-interval=5s \
83+
CMD curl -f http://localhost/ || exit 1
84+
6285
WORKDIR ${WEBSERVER_HOME}
6386
EXPOSE 80
6487
EXPOSE 443

0 commit comments

Comments
 (0)