Hello. I has been trying to up my api backend by docker to render, however , i have had problems that carry me here. firstable , my docker service works at local. second, i have been updating the docker-compose.yml and docker file a lot of times seaching answers… the firt problem was with the api routes, it doestn have accees , show my index, but in api routes shows a forbbiden 403. then of a lot of info , documentation and more , y change the files mentioned ,and finlly with my docker running on local, come here to ask help with and 500 error. i proved changed the enviroment variable of the port , and it doesnt works, but show that the service is running , and that detect activity on the 80 port wich is i exposed…i hope u can help me i have been workin on this error about 3 weeks everyday. thank u so much for yuor time, and excuses about my english i speak spanish.
Hi there,
It’s hard to know why your service gives a 500 response. I suggest changing your Apache configuration to write to STDOUT/STDERR. Change these two config lines to:
ErrorLog /dev/stderrTransferLog /dev/stdout
I would also recommend changing your LOG_CHANNEL
environment variable to stderr
so Larvel logs end up in your service logs.
My guess is that your environment isn’t set correctly. For example your DB_*
settings look to point to a non-existing MySQL database.
Regards,
Keith
Render Support, UTC+10
thank u for answer me … i did the changes and try other config. i have this…docker compose.yml services:
backend:
build:
context: .
dockerfile: dockerfile
ports:
- “8000:80”
networks:
- juca_backend-network
environment:
- APP_ENV=production
- APP_DEBUG=true
- APP_KEY=base64:3wFgN68MPXb3KLOuBlxg7YAx9Q9+nXUOMZX3sbK3bUs=
- DB_CONNECTION=mysql
- DB_HOST=mysql
- DB_PORT=3306
- DB_DATABASE=apibackend
- DB_USERNAME=root
- DB_PASSWORD=codigo1mysql
volumes:
- ./apibackend:/var/www/html
depends_on:
- mysql
mysql:
image: mysql:5.7
container_name: juca-mysql-1
environment:
MYSQL_ROOT_PASSWORD: ****
MYSQL_DATABASE: apibackend
MYSQL_USER: root
MYSQL_PASSWORD: *****
networks:
- juca_backend-network
volumes:
- dbdata:/var/lib/mysql
ports:
- “3306:3306”
networks:
juca_backend-network:
driver: bridge
volumes:
dbdata:
it works with a dockerfile to the local. i created another dockerfile.render to render, i specificate this on render config , and have a start file commands… there are the dockerfile.render…:# Usar la imagen oficial de PHP con Apache
FROM php:8.3-apache
Instalar extensiones de PHP necesarias y herramientas adicionales
RUN apt-get update &&
apt-get install -y
git
unzip
libzip-dev
netcat-openbsd
&& docker-php-ext-install pdo pdo_mysql zip
&& apt-get clean && rm -rf /var/lib/apt/lists/*
Instalar Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
Establecer el directorio de trabajo
WORKDIR /var/www/html
Copiar el código de la aplicación al contenedor
COPY apibackend/ .
Instalar dependencias de Composer
RUN composer install --no-interaction --no-dev --optimize-autoloader
Establecer permisos para el almacenamiento y caché
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
Habilitar mod_rewrite de Apache
RUN a2enmod rewrite
Copiar la configuración de Apache
COPY apache-config.conf /etc/apache2/sites-available/000-default.conf
Crear script de inicio
RUN echo ‘#!/bin/bash\n
# Esperar a que la base de datos esté disponible\n
while ! nc -z mysql 3306; do\n
sleep 3\n
done\n
# Ejecutar migraciones de Laravel\n
php artisan migrate --force\n
# Iniciar Apache\n
apache2-foreground’ > /usr/local/bin/start.sh
&& chmod +x /usr/local/bin/start.sh
Exponer el puerto que utilizará Apache
EXPOSE 80
Comando para ejecutar el script de inicio
CMD [“/usr/local/bin/start.sh”]
and file to start …#!/bin/bash
Esperar a que la base de datos esté disponible
while ! nc -z mysql 3306; do
sleep 1
done
Ejecutar migraciones de Laravel
php artisan migrate --force
Iniciar Apache
apache2-foreground
and it looks like this on rnedr desktop, it works whit another dockerfile…
finally i have benn changing the name of dbhost, to local host , to mysl to juca-mysql-1, and dont have result…this the losg that i have actually on render… ==> Deploying…
Aug 13 03:06:15 PMnc: getaddrinfo for host “mysql” port 3306: Name or service not known
Hi there,
You need a MySQL service. You can deploy your own service on Render (this can run for free) or use a 3rd party service. You could also use PostgreSQL instead of MySQL.
Regards,
Keith
Render Support, UTC+10
i made an postgres db service on render , change de enviroment data and show this Oops! An Error Occurred
The server returned a “500 Internal Server Error”.
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.