I was trying to deploy one of my laravel app, however, i always getting the same error, which is
Failed due to unhealthy allocations
I read that it could be a port miss match issue, however, i tried to change port multiple time, and still not luck. Can anyone tell me what am i missing?
fly.toml
[[services]]
internal_port = 8000
protocol = "tcp"
[services.concurrency]
hard_limit = 50
soft_limit = 20
[[services.http_checks]]
grace_period = "2s"
interval = 8000
method = "get"
path = "/health"
protocol = "http"
restart_limit = 5
timeout = 2000
tls_skip_verify = true
[[services.ports]]
force_https = true
handlers = ["http"]
port = 22
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "2s"
interval = 8000
timeout = 2000
Docker file
ARG PHP_VERSION= 7.4
FROM php:7.4-fpm as base
LABEL fly_launch_runtime="laravel"
RUN apt-get update && apt-get install -y \
git curl zip unzip rsync ca-certificates vim htop cron \
# php${DOCKER_VERSION}-pgsql php7.4-bcmath \
# php${DOCKER_VERSION}-swoole php7.4-xml php7.4-mbstring \
# docker-php-ext-install \
# docker-php-ext-configure \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
# libpng-dev \
# libjpeg62-turbo-dev \
libfreetype6-dev \
libonig-dev \
locales \
libzip-dev \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
libxml2-dev
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl posix
# RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/
RUN docker-php-ext-install gd soap
ENV PHP_MEMORY_LIMIT=1G
# RUN echo "php_admin_value[memory_limit] = 2G" >> /usr/local/etc/php-fpm.d/www.conf
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
FROM base as installer
ARG env_name=prod
# Copy existing application directory contents
COPY ./ /var/www/html
# Copy existing application directory permissions
WORKDIR /var/www/html
RUN composer install --optimize-autoloader --no-dev \
&& mkdir -p storage/logs \
# && php artisan cache:clear \
# && chown -R webuser:webgroup /var/www/html \
# && sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \
&& echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
&& rm -rf /etc/cont-init.d/* \
# && cp docker/nginx-websockets.conf /etc/nginx/conf.d/websockets.conf \
&& cp docker/entrypoint.sh /entrypoint \
&& chmod +x /entrypoint
RUN rm -rf .git
FROM base as release
WORKDIR /var/www/html
COPY --from=installer --chown=www-data:www-data /var/www/html /app
USER www-data
# Expose port 9000 and start php-fpm server
EXPOSE 8000
VM status
Instance
ID = 5971bce5
Process = app
Version = 17
Region = sea
Desired = stop
Status = failed
Health Checks =
Restarts = 2
Created = 50s ago
Events
TIMESTAMP TYPE MESSAGE
2022-09-21T19:00:39Z Received Task received by client
2022-09-21T19:00:39Z Task Setup Building Task Directory
2022-09-21T19:00:46Z Started Task started by client
2022-09-21T19:00:48Z Terminated Exit Code: 78
2022-09-21T19:00:48Z Restarting Task restarting in 1.202383176s
2022-09-21T19:00:57Z Started Task started by client
2022-09-21T19:00:59Z Terminated Exit Code: 78
2022-09-21T19:00:59Z Restarting Task restarting in 1.180712906s
2022-09-21T19:01:10Z Started Task started by client
2022-09-21T19:01:12Z Terminated Exit Code: 78
2022-09-21T19:01:12Z Not Restarting Exceeded allowed attempts 2 in interval 5m0s and mode is "fail"
2022-09-21T19:01:12Z Alloc Unhealthy Unhealthy because of failed task
2022-09-21T19:01:13Z Killing Sent interrupt. Waiting 2m0s before force killing
Checks
ID SERVICE STATE OUTPUT
Recent Logs
2022-09-21T19:00:46Z [info]Preparing to run: `docker-php-entrypoint php-fpm` as www-data
2022-09-21T19:00:46Z [info]2022/09/21 19:00:46 listening on [fdaa:0:9edc:a7b:bcab:5971:bce5:2]:22 (DNS: [fdaa::3]:53)
2022-09-21T19:00:47Z [info]Starting clean up.
2022-09-21T19:00:54Z [info]Starting instance
2022-09-21T19:00:56Z [info]Configuring virtual machine
2022-09-21T19:00:56Z [info]Pulling container image
2022-09-21T19:00:56Z [info]Unpacking image
2022-09-21T19:00:56Z [info]Preparing kernel init
2022-09-21T19:00:57Z [info]Configuring firecracker
2022-09-21T19:00:57Z [info]Starting virtual machine
2022-09-21T19:00:57Z [info]Starting init (commit: 249766e)...
2022-09-21T19:00:57Z [info]Preparing to run: `docker-php-entrypoint php-fpm` as www-data
2022-09-21T19:00:57Z [info]2022/09/21 19:00:57 listening on [fdaa:0:9edc:a7b:bcab:5971:bce5:2]:22 (DNS: [fdaa::3]:53)
2022-09-21T19:00:58Z [info]Starting clean up.
2022-09-21T19:01:04Z [info]Starting instance
2022-09-21T19:01:08Z [info]Configuring virtual machine
2022-09-21T19:01:08Z [info]Pulling container image
2022-09-21T19:01:09Z [info]Unpacking image
2022-09-21T19:01:09Z [info]Preparing kernel init
2022-09-21T19:01:10Z [info]Configuring firecracker
2022-09-21T19:01:10Z [info]Starting virtual machine
2022-09-21T19:01:10Z [info]Starting init (commit: 249766e)...
2022-09-21T19:01:10Z [info]Preparing to run: `docker-php-entrypoint php-fpm` as www-data
2022-09-21T19:01:10Z [info]2022/09/21 19:01:10 listening on [fdaa:0:9edc:a7b:bcab:5971:bce5:2]:22 (DNS: [fdaa::3]:53)
2022-09-21T19:01:11Z [info]Starting clean up.