Trouble in deploying my laravel app with docker on render

Hi i hope someone can help me. I’m trying to deploy my laravel with docker on render. But when i try to deploy it . The logs will always says

Pushing image to registry…

Oct 17 12:05:55 AMUpload succeeded

Oct 17 12:05:57 AM==> Deploying…

Oct 17 12:06:11 AM==> Exited with status 128

Oct 17 12:06:11 AM==> Common ways to troubleshoot your deploy: Troubleshooting Your Deploy – Render Docs

It doesn’t provide any info beside exited with status 128

This is my Dockerfile

Use the official PHP 8.2 with Apache image

FROM php:8.2-apache as php

RUN apt-get update -y

RUN apt-get install -y unzip libpq-dev libcurl4-gnutls-dev

RUN docker-php-ext-install pdo pdo_mysql bcmath

RUN apt-get install nano

RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \

&& apt-get install -y nodejs

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

COPY . .

Ensure the entrypoint script is copied

COPY ./Docker/entrypoint.sh /docker/entrypoint.sh

Set permissions for the entrypoint script

RUN chmod +x /docker/entrypoint.sh

ENV COMPOSER_ALLOW_SUPERUSER=1

RUN composer install --no-dev --optimize-autoloader

RUN rm -rf node_modules package-lock.json

RUN apt-get clean

ENV PORT=8000

ENTRYPOINT [ “docker/entrypoint.sh” ]

render.yaml

services:

  • type: web
    name: php-app
    env: docker
    plan: starter
    dockerfilePath: ./Dockerfile
    envVars:

    • key: APP_ENV
      value: production # Set to production for deployments
    • key: CONTAINER_ROLE
      value: app
      startCommand: |
      /docker/entrypoint.sh
      autoDeploy: true
      envVarGroups:
    • prod-vars
  • type: managed_mysql
    name: db
    plan: starter
    databases:

    • name: ${DB_DATABASE}
      envVars:
    • key: MYSQL_DATABASE
      value: ${DB_DATABASE}
    • key: MYSQL_USER
      value: ${DB_USERNAME}
    • key: MYSQL_PASSWORD
      value: ${DB_PASSWORD}
    • key: MYSQL_ROOT_PASSWORD
      value: ${DB_PASSWORD}

envVarGroups:

  • name: prod-vars
    envVars:
    • key: DB_DATABASE
      value: edm_mls
    • key: DB_USERNAME
      value: admin
    • key: DB_PASSWORD
      value: secret

entrypoint.sh

#!/bin/sh

PORT=${PORT:-8000}

Run key Laravel commands

php artisan key:generate || echo “Key generate failed”

php artisan migrate || echo “Migration failed”

php artisan db:seed || echo “Seeding failed”

php artisan cache:clear

php artisan config:clear

php artisan route:clear

php artisan storage:link

Build assets for production

npm install

npm run build

Start Laravel

exec php artisan serve --port=${PORT} --host=0.0.0.0 --env=.env

Hey,

Exit Code 128 means that code within the container triggered an exit command but didn’t provide a valid exit code. We usually see this when commands in the Dockerfile reference executables that aren’t installed in the environment or point to the wrong path. It’s often an error in your Dockerfile configuration.

In your case, it seems like docker/entrypoint.sh couldn’t be found at that specific location in your repo where you’re deploying the Docker container. It looks like what you’ve shared might be from a tool like GPT-4, so make sure you fully understand what you’re deploying, as the instructions could be incomplete depending on your use case. You should successfully deploy this container locally first before trying it on Render.

Jérémy.
Render Support, UTC+3

Hi sir.
Thank you for your reply. my Dockerfile was in the root folder of my repo. also the entrypoint.sh was also on the root folder inside a Docker folder.

i already test it on my local machine and it works fine but when i try to deploy it on render. the exit status code 128 appear.

Hey,

In the first line of your Dockerfile, you’re copying the entrypoint.sh file to a ‘/docker’ folder located in the root of the filesystem, not within your project directory:

RUN chmod +x /docker/entrypoint.sh

But then you run the .sh file from the current directory:

ENTRYPOINT [“docker/entrypoint.sh”]

Jérémy.
Render Support, UTC+3