Browse Source

Docker healthcheck+ labels (#2438)

* Add Docker labels

And try to fix the platform metadata for ARM, and add health check

* Execution rights

* Remove experimental features not supported by Docker Hub

"--squash" is only supported on a Docker daemon with experimental
features enabled. build hook failed! (1)

* Fix paths
Alexandre Alapetite 6 years ago
parent
commit
8c2cf1b4dd
6 changed files with 90 additions and 4 deletions
  1. 20 1
      Docker/Dockerfile
  2. 20 0
      Docker/Dockerfile-Alpine
  3. 24 2
      Docker/Dockerfile-QEMU-ARM
  4. 22 0
      Docker/hooks/build
  5. 3 1
      Docker/hooks/pre_build
  6. 1 0
      app/install.php

+ 20 - 1
Docker/Dockerfile

@@ -5,7 +5,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
 
 RUN apt update && \
 	apt install --no-install-recommends -y \
-	ca-certificates cron \
+	ca-certificates cron curl \
 	apache2 libapache2-mod-php \
 	php-curl php-intl php-mbstring php-xml php-zip \
 	php-sqlite3 php-mysql php-pgsql && \
@@ -17,6 +17,22 @@ WORKDIR /var/www/FreshRSS
 COPY . /var/www/FreshRSS
 COPY ./Docker/*.Apache.conf /etc/apache2/sites-available/
 
+ARG FRESHRSS_VERSION
+ARG SOURCE_BRANCH
+ARG SOURCE_COMMIT
+
+LABEL \
+	org.opencontainers.image.authors="Alkarex" \
+	org.opencontainers.image.description="A self-hosted RSS feed aggregator" \
+	org.opencontainers.image.documentation="https://freshrss.github.io/FreshRSS/" \
+	org.opencontainers.image.licenses="AGPL-3.0" \
+	org.opencontainers.image.revision="${SOURCE_BRANCH}.${SOURCE_COMMIT}" \
+	org.opencontainers.image.source="https://github.com/FreshRSS/FreshRSS" \
+	org.opencontainers.image.title="FreshRSS" \
+	org.opencontainers.image.url="https://freshrss.org/" \
+	org.opencontainers.image.vendor="FreshRSS" \
+	org.opencontainers.image.version="$FRESHRSS_VERSION"
+
 RUN a2dismod -f alias autoindex negotiation status && \
 	a2enmod deflate expires headers mime setenvif && \
 	a2disconf '*' && \
@@ -38,3 +54,6 @@ EXPOSE 80
 CMD ([ -z "$CRON_MIN" ] || cron) && \
 	. /etc/apache2/envvars && \
 	exec apache2 -D FOREGROUND
+
+HEALTHCHECK --start-period=8s --interval=67s --timeout=5s --retries=3 \
+	CMD curl -fsS 'http://localhost/i/' | grep -q 'jsonVars' || exit 1

+ 20 - 0
Docker/Dockerfile-Alpine

@@ -3,6 +3,7 @@ FROM alpine:3.10
 ENV TZ UTC
 
 RUN apk add --no-cache \
+	curl \
 	apache2 php7-apache2 \
 	php7 php7-curl php7-gmp php7-intl php7-mbstring php7-xml php7-zip \
 	php7-ctype php7-dom php7-fileinfo php7-iconv php7-json php7-session php7-simplexml php7-xmlreader php7-zlib \
@@ -14,6 +15,22 @@ WORKDIR /var/www/FreshRSS
 COPY . /var/www/FreshRSS
 COPY ./Docker/*.Apache.conf /etc/apache2/conf.d/
 
+ARG FRESHRSS_VERSION
+ARG SOURCE_BRANCH
+ARG SOURCE_COMMIT
+
+LABEL \
+	org.opencontainers.image.authors="Alkarex" \
+	org.opencontainers.image.description="A self-hosted RSS feed aggregator" \
+	org.opencontainers.image.documentation="https://freshrss.github.io/FreshRSS/" \
+	org.opencontainers.image.licenses="AGPL-3.0" \
+	org.opencontainers.image.revision="${SOURCE_BRANCH}.${SOURCE_COMMIT}" \
+	org.opencontainers.image.source="https://github.com/FreshRSS/FreshRSS" \
+	org.opencontainers.image.title="FreshRSS" \
+	org.opencontainers.image.url="https://freshrss.org/" \
+	org.opencontainers.image.vendor="FreshRSS" \
+	org.opencontainers.image.version="$FRESHRSS_VERSION"
+
 RUN rm -f /etc/apache2/conf.d/languages.conf /etc/apache2/conf.d/info.conf \
 		/etc/apache2/conf.d/status.conf /etc/apache2/conf.d/userdir.conf && \
 	sed -r -i "/^\s*LoadModule .*mod_(alias|autoindex|negotiation|status).so$/s/^/#/" \
@@ -34,3 +51,6 @@ ENTRYPOINT ["./Docker/entrypoint.sh"]
 EXPOSE 80
 CMD ([ -z "$CRON_MIN" ] || crond -d 6) && \
 	exec httpd -D FOREGROUND
+
+HEALTHCHECK --start-period=8s --interval=67s --timeout=5s --retries=3 \
+	CMD curl -fsS 'http://localhost/i/' | grep -q 'jsonVars' || exit 1

+ 24 - 2
Docker/Dockerfile-QEMU-ARM

@@ -4,14 +4,14 @@
 FROM arm32v7/ubuntu:19.04
 
 # Requires ./hooks/*
-COPY ./Docker/qemu-* /usr/bin/
+COPY ./Docker/qemu-arm-* /usr/bin/
 
 ENV TZ UTC
 RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
 
 RUN apt update && \
 	apt install --no-install-recommends -y \
-	ca-certificates cron \
+	ca-certificates cron curl \
 	apache2 libapache2-mod-php \
 	php-curl php-intl php-mbstring php-xml php-zip \
 	php-sqlite3 php-mysql php-pgsql && \
@@ -23,6 +23,22 @@ WORKDIR /var/www/FreshRSS
 COPY . /var/www/FreshRSS
 COPY ./Docker/*.Apache.conf /etc/apache2/sites-available/
 
+ARG FRESHRSS_VERSION
+ARG SOURCE_BRANCH
+ARG SOURCE_COMMIT
+
+LABEL \
+	org.opencontainers.image.authors="Alkarex" \
+	org.opencontainers.image.description="A self-hosted RSS feed aggregator" \
+	org.opencontainers.image.documentation="https://freshrss.github.io/FreshRSS/" \
+	org.opencontainers.image.licenses="AGPL-3.0" \
+	org.opencontainers.image.revision="${SOURCE_BRANCH}.${SOURCE_COMMIT}" \
+	org.opencontainers.image.source="https://github.com/FreshRSS/FreshRSS" \
+	org.opencontainers.image.title="FreshRSS" \
+	org.opencontainers.image.url="https://freshrss.org/" \
+	org.opencontainers.image.vendor="FreshRSS" \
+	org.opencontainers.image.version="$FRESHRSS_VERSION"
+
 RUN a2dismod -f alias autoindex negotiation status && \
 	a2enmod deflate expires headers mime setenvif && \
 	a2disconf '*' && \
@@ -36,6 +52,9 @@ RUN sed -r -i "/^\s*(CustomLog|ErrorLog|Listen) /s/^/#/" /etc/apache2/apache2.co
 		su www-data -s /bin/sh -c 'php /var/www/FreshRSS/app/actualize_script.php' \
 		2>> /proc/1/fd/2 > /tmp/FreshRSS.log" | crontab -
 
+# Useful with the `--squash` build option
+RUN rm /usr/bin/qemu-*
+
 ENV COPY_SYSLOG_TO_STDERR On
 ENV CRON_MIN ''
 ENTRYPOINT ["./Docker/entrypoint.sh"]
@@ -44,3 +63,6 @@ EXPOSE 80
 CMD ([ -z "$CRON_MIN" ] || cron) && \
 	. /etc/apache2/envvars && \
 	exec apache2 -D FOREGROUND
+
+HEALTHCHECK --start-period=8s --interval=67s --timeout=5s --retries=3 \
+	CMD curl -fsS 'http://localhost/i/' | grep -q 'jsonVars' || exit 1

+ 22 - 0
Docker/hooks/build

@@ -0,0 +1,22 @@
+#!/bin/bash
+
+cd ..
+FRESHRSS_VERSION=`grep "'FRESHRSS_VERSION'" constants.php | cut -d "'" -f4`
+echo "$FRESHRSS_VERSION"
+
+if [[ "$DOCKERFILE_PATH" == *-ARM ]]
+then
+	#TODO: Add --squash --platform arm options when Docker Hub deamon supports them
+	docker build \
+		--build-arg FRESHRSS_VERSION="$FRESHRSS_VERSION" \
+		--build-arg SOURCE_BRANCH="$SOURCE_BRANCH" \
+		--build-arg SOURCE_COMMIT="$SOURCE_COMMIT" \
+		-f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" .
+else
+	#TODO: Add --squash option when Docker Hub deamon supports it
+	docker build \
+		--build-arg FRESHRSS_VERSION="$FRESHRSS_VERSION" \
+		--build-arg SOURCE_BRANCH="$SOURCE_BRANCH" \
+		--build-arg SOURCE_COMMIT="$SOURCE_COMMIT" \
+		-f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" .
+fi

+ 3 - 1
Docker/hooks/pre_build

@@ -1,6 +1,8 @@
 #!/bin/bash
 
-if [[ "$DOCKERFILE_PATH" == *-ARM ]];
+cp README.md ../
+
+if [[ "$DOCKERFILE_PATH" == *-ARM ]]
 then
 	# https://github.com/balena-io/qemu
 	# Download a local copy of QEMU on Docker Hub build machine

+ 1 - 0
app/install.php

@@ -724,6 +724,7 @@ case 5:
 	<head>
 		<meta charset="UTF-8" />
 		<meta name="viewport" content="initial-scale=1.0" />
+		<script id="jsonVars" type="application/json">{}</script>
 		<title><?php echo _t('install.title'); ?></title>
 		<link rel="stylesheet" href="../themes/base-theme/template.css?<?php echo @filemtime(PUBLIC_PATH . '/themes/base-theme/template.css'); ?>" />
 		<link rel="stylesheet" href="../themes/Origine/origine.css?<?php echo @filemtime(PUBLIC_PATH . '/themes/Origine/origine.css'); ?>" />