Unable to deploy due to allocations

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?


  internal_port = 8000
  protocol = "tcp"
    hard_limit = 50
    soft_limit = 20

    grace_period = "2s"
    interval = 8000
    method = "get"
    path = "/health"
    protocol = "http"
    restart_limit = 5
    timeout = 2000
    tls_skip_verify = true

    force_https = true
    handlers = ["http"]
    port = 22

    handlers = ["tls", "http"]
    port = 443

    grace_period = "2s"
    interval = 8000
    timeout = 2000

Docker file


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 \

# 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


# 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

VM status

  ID            = 5971bce5  
  Process       = app       
  Version       = 17        
  Region        = sea       
  Desired       = stop      
  Status        = failed    
  Health Checks =           
  Restarts      = 2         
  Created       = 50s ago   

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              


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.

OK, a few things!

It looks like you sort of copied/pasted a bunch of stuff from various sources. This may have led to some issues.

Notably you may have started with a really early version of the fly launch output for Laravel and adjusted it?

Here’s a few issues I can spot:

  1. I don’t see a web server installed. The base container php:7.4-fpm has PHP-FPM installed, but no web server (apache/nginx). So, there’s nothing actually accepting web requests running in the container. No allocations will pass any health checks in that case!
  2. Your health checks assume a web server will be listening on port 8000. That’s great but it means configuring stuff when you get a web server running in the container - just be aware.
  3. The following section is defining port 22 for some reason (SSH?) but is using an http handler / force_https.
    force_https = true
    handlers = ["http"]
    port = 22

I think that is meant to be port 80?

I think overall you’ll have the easiest time running fly launch again to start a new project/app and letting the created “stuff” run a Laravel application.

The docs has examples of selecting PHP version and making other adjustments from that setup: Run a Laravel App · Fly Docs

Yea, the dockerfile is copied from my another project. However, that project is use with kubernetes and AWS. I guess thats a mistake from my side.

Thanks for pointing out the web server thing, a big oversight

Gotcha! Some of the things looked like Docker configurations we used in the past for the fly launch setup as well - perhaps not!

LMK how it goes!

Yes, it works, thanks a lot