Skip to content

thayronarrais/docker-laravel-postgres-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-laravel-postgres-nginx

Simple docker-compose for Laravel, with postgresql, redis, nginx and php-fpm

Pre-requisites

  • Docker running on the host machine.
  • Docker compose running on the host machine.
  • Basic knowledge of Docker.

Installation

  • To get started, the following steps needs to be taken:
  • Clone the repo.
  • cd docker-laravel-postgres-nginx to the project directory.
  • cd to web and run the command to create a new Laravel project into application directory.
  • cd .. to back the project directory.
  • cp .env.example .env to use env config file
  • Edit .env and set PHP_VERSION to the desired PHP release (e.g. 7.4, 8.1)
  • Run docker-compose up -d to start the containers.
  • Visit http://localhost to see your Laravel application.
  • Try to connect 127.0.0.1:5432 to access Postgres
  • After starting, note that one directory and one file will be created with name postgres and file data, this files are Database archives

usage:

  • docker-compose up -d to start all containers
  • docker-compose down to stop all containers
  • If you need to restart after modifying docker-compose.yml restart with docker-compose down and docker-compose up -d
  • Run pytest to execute the tests

Images

  • redis:alpine

  • postgres:9.5-alpine

  • nginx:alpine

  • php-fpm image according to PHP_VERSION in .env

SourceFiles

Inside the sourcefiles directory there are other directories: php-fpm and nginx:

php-fpm: Extensions PHP and PHP.INI

  • Dockerfile installs pgsql and gd for the configured PHP version along with php-redis
  • php-ini-overrides.ini

nginx: nginx.conf

  • file conf nginx

volumes:

  • nginx folder
  • php-ini-overrides.ini
  • data(postgres)

multiple servers:

  • create file conf of nginx in nginx directory you should use default.conf as example
  • restart containers: docker-compose down and docker-compose up -d

Troubleshooting

If you need to restart after modifying Dockerfile and have Troubleshooting:

  • Verify all containers running: docker ps -a
  • Stop all containers and remove: docker stop $(docker ps -a -q) and docker rm $(docker ps -a -q)
  • Try to start again docker-compose up -d

About

Simple docker-compose for Laravel, with postgresql, reddis, nginx, php-fpm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •