health-check and migrate on boot (#25)
All checks were successful
All checks were successful
add a health check to the container and option to artisan migrate on boot Co-authored-by: Ruben Momoa <ruben.lobbes@lobbes.nl> Reviewed-on: #25
This commit was merged in pull request #25.
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
matrix:
|
matrix:
|
||||||
PHP_VERSION:
|
PHP_VERSION:
|
||||||
- 8
|
|
||||||
- 8.3
|
|
||||||
- 8.2
|
|
||||||
- 8.1
|
- 8.1
|
||||||
|
- 8.2
|
||||||
|
- 8.3
|
||||||
|
- 8
|
||||||
|
|
||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ FROM php:${BASE_VERSION}-fpm-alpine
|
|||||||
# port to for the webserver
|
# port to for the webserver
|
||||||
ENV WEBSERVER_PORT=8080
|
ENV WEBSERVER_PORT=8080
|
||||||
|
|
||||||
|
# path without leading / (slash)
|
||||||
|
ENV HEALTHCHECK_PATH=""
|
||||||
|
|
||||||
COPY start-container.sh /usr/local/bin/start-container
|
COPY start-container.sh /usr/local/bin/start-container
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
@@ -32,6 +35,9 @@ RUN apk add --no-cache \
|
|||||||
&& docker-php-ext-install filter pdo_mysql \
|
&& docker-php-ext-install filter pdo_mysql \
|
||||||
&& chmod +x /usr/local/bin/start-container
|
&& chmod +x /usr/local/bin/start-container
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=5m --timeout=3s --start-period=5m --start-interval=10s \
|
||||||
|
CMD curl -f http://localhost:${WEBSERVER_PORT}/${HEALTHCHECK_PATH} || exit 1
|
||||||
|
|
||||||
EXPOSE ${WEBSERVER_PORT}
|
EXPOSE ${WEBSERVER_PORT}
|
||||||
|
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
# exit when any command fails
|
# exit when any command fails
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
if [ ! -f /var/www/html/artisan ]; then
|
||||||
|
echo "No existing Laravel project found"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# install extra packages and extensions on first boot
|
# install extra packages and extensions on first boot
|
||||||
if [[ $(id -u) -eq 0 && ! -f /etc/first_boot ]]; then
|
if [[ $(id -u) -eq 0 && ! -f /etc/first_boot ]]; then
|
||||||
if [[ -n "${EXTRA_APK_PACKAGES// /}" ]]; then
|
if [[ -n "${EXTRA_APK_PACKAGES// /}" ]]; then
|
||||||
@@ -26,9 +31,9 @@ if [[ "$BOOT_NPM_INSTALL" = true ]]; then
|
|||||||
npm install --cache /tmp/npm
|
npm install --cache /tmp/npm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f /var/www/html/artisan ]; then
|
if [[ "$BOOT_MIGRATE" = true ]]; then
|
||||||
echo "No existing Laravel project found"
|
echo "artisan migrate"
|
||||||
exit
|
php /var/www/html/artisan migrate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$BOOT_NPM_DEV" = true ]]; then
|
if [[ "$BOOT_NPM_DEV" = true ]]; then
|
||||||
|
|||||||
@@ -12,14 +12,22 @@ fi
|
|||||||
version=$1
|
version=$1
|
||||||
|
|
||||||
# Suffix
|
# Suffix
|
||||||
[[ -n $2 ]] && suffix="-$2" || suffix=""
|
suffix=""
|
||||||
|
if [[ -n $2 ]]; then
|
||||||
|
suffix="-$2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch tags.txt
|
||||||
|
if [[ "$2" = "php-8" ]]; then
|
||||||
|
echo "latest" >> tags.txt
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if the first character is "V" or "v" and remove it
|
# Check if the first character is "V" or "v" and remove it
|
||||||
if [[ "${version:0:1}" == "V" || "${version:0:1}" == "v" ]]; then
|
if [[ "${version:0:1}" == "V" || "${version:0:1}" == "v" ]]; then
|
||||||
version="${version#?}"
|
version="${version#?}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "latest$suffix" > tags.txt
|
echo "latest$suffix" >> tags.txt
|
||||||
echo "$version" | cut -d'.' -f1 | xargs -I {} echo "{}$suffix" >> tags.txt
|
echo "$version" | cut -d'.' -f1 | xargs -I {} echo "{}$suffix" >> tags.txt
|
||||||
echo "$version" | cut -d'.' -f1,2 | xargs -I {} echo "{}$suffix" >> tags.txt
|
echo "$version" | cut -d'.' -f1,2 | xargs -I {} echo "{}$suffix" >> tags.txt
|
||||||
echo "$version" | cut -d'.' -f1,2,3 | xargs -I {} echo "{}$suffix" >> tags.txt
|
echo "$version" | cut -d'.' -f1,2,3 | xargs -I {} echo "{}$suffix" >> tags.txt
|
||||||
Reference in New Issue
Block a user