Please help with code for dockerfile and docker-compose file i need laravel setup and postgres.
This is my docker file
FROM php:7.4
RUN apt-get update && apt-get install -y
libfreetype6-dev
libjpeg62-turbo-dev
libmcrypt-dev
libpng-dev
zlib1g-dev
libpq-dev
libxml2-dev
libzip-dev
libonig-dev
graphviz
&& docker-php-ext-configure gd
&& docker-php-ext-install -j$(nproc) gd
&& docker-php-ext-install pdo_mysql
&& docker-php-ext-install pdo_psql
&& docker-php-ext-install zip
&& docker-php-ext-install sockets
&& docker-php-source delete
&& curl -sS https://getcomposer.org/installer | php --
--install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www/html
COPY . .
RUN composer install
CMD php artisan serve --host=0.0.0.0
EXPOSE 8000
this is docker-compose.yml file
version: '3'
services:
php_4:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./:/var/www/html
ports:
- "8000:8000"
depends_on:
- postgres_4
postgres_4:
image: postgres
restart: unless-stopped
ports:
- "5433:5432"
volumes:
- ./docker/postgres:/var/lib/postgresql/data
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: lara_4
POSTGRES_HOST_AUTH_METHOD: "trust"
Both are not working giving different different errors. SO please anyone give fresh code for both dockerfile and docker-compose file for laravel with postgresql using docker.
2
Answers
You should specify web server, i.e. nginx in docker-compose.yml file
You should take a look at Laravel Sail if you’re just starting out with Laravel + Docker.
For your question in general, please edit your question and insert the specific errors.