{"id":17194262,"url":"https://github.com/saiteja13427/docker-laravel","last_synced_at":"2026-04-17T19:01:35.354Z","repository":{"id":161564505,"uuid":"502322324","full_name":"saiteja13427/Docker-Laravel","owner":"saiteja13427","description":"🐋 A completely dockerised multicontainer setup using which you can have a laravel development environment without installing anything except docker. You can have a fully functional laravel development environment locally with just two commands.","archived":false,"fork":false,"pushed_at":"2022-06-11T10:55:18.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T07:31:53.490Z","etag":null,"topics":["docker","docker-compose","dockerfile","laravel","laravel-development","laravel-environment","laravel-framework","laravel-installation"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saiteja13427.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-11T10:54:16.000Z","updated_at":"2022-12-27T13:20:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"abcfc8bc-a8b6-4481-893c-8f829d824993","html_url":"https://github.com/saiteja13427/Docker-Laravel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/saiteja13427/Docker-Laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiteja13427%2FDocker-Laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiteja13427%2FDocker-Laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiteja13427%2FDocker-Laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiteja13427%2FDocker-Laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saiteja13427","download_url":"https://codeload.github.com/saiteja13427/Docker-Laravel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiteja13427%2FDocker-Laravel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31941845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","dockerfile","laravel","laravel-development","laravel-environment","laravel-framework","laravel-installation"],"created_at":"2024-10-15T01:46:26.609Z","updated_at":"2026-04-17T19:01:35.338Z","avatar_url":"https://github.com/saiteja13427.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Setup For Laravel\n\nThis is a complete docker setup for developing, running and deploying a laravel application without going through the tiring process of installing php, nginx and a ton of packages required to run laravel.\n\nYou can just have the environment ready for development with two commands\n\n1. `docker-compose run --rm composer create-project laravel/laravel .`\n2. `docker-compose up -d server`\n\nYou will have your laravel project in src folder and you can see it on `localhost:8080`\n\nIn case you are cusrious and want to understand the configurations\n\nHere is a detailed explanation of all the containers that we launch here.\n\n## Configurations\n\n### PHP\n\nThis is about main php container.\n\nWe have some extra configs so we have a separate docker file for php\n\n```docker\nFROM php:8.1-fpm-alpine\n\n# This is the standard working directory for servers\nWORKDIR /var/www/html\n\n# To install pdo and pdo_mysql to talk to mysql\nRUN docker-php-ext-install pdo pdo_mysql\n\n# Adding a user\nRUN addgroup -g 1000 laravel \u0026\u0026 adduser -G laravel -g laravel -s /bin/sh -D laravel\n\n# Using that created user\nUSER laravel\n```\n\nThen coming to the php part in docker-compose file, we just set the build to the above docker file and add a bind mount for code reflection to src.\n\n**Note:** We are adding :delegated to bind mount so that the changes are processed in batches to improve performance.\n\n**Note:** PHP official image exposes 9000 port. Thus we have 9000 port in nginx\n\n### Nginx\n\n```C\n  // set the image to nginx\n  server:\n    image: 'nginx:stable-alpine'\n    //Set the source code bind mount and nginx conf bind mount\n    volumes:\n      - ./src:/var/www/html\n      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro\n    // Port Mapping\n    ports:\n      - \"8080:80\"\n    // Some nginx environmnet variables\n    environment:\n      - NGINX_HOST=foobar.com\n      - NGINX_PORT=80\n    // Dependecies\n    depends_on:\n      - php\n      - mysql\n```\n\n- nginx.conf has got `fastcgi_pass php:9000;`, here we have php:9000 because all containers are in same network and our php container is identified by name by docker thus we have php:9000 instead of IP:9000.\n\n- We are also adding /src as a bind mount to /var/www/html as server also needs to know about our source code. At nginx.conf `root /var/www/html/public;`\n\n### MYSQL\n\n```C\n  mysql:\n    // Using the official mysql image\n    image: mysql:5.7\n    //Pointing it to env file with username, db and password which you need to edit\n    env_file:\n      - ./env/mysql.env\n```\n**Note:** Dont't forget to set a default db, user, password and root password in the env/mysql.env file\n\n### Composer\n\nComposer is used to generate laravel code and is thus here as a utility container.\n\n\nThe dockerfile goes like this\n\n```docker\n# Official composer image\nFROM composer:latest\n\n# Adding users\nRUN addgroup -g 1000 laravel \u0026\u0026 adduser -G laravel -g laravel -s /bin/sh -D laravel\n\n# Using that user so that we don't get any persmission issues\nUSER laravel\n\n# Setting a workdir\nWORKDIR /var/www/html\n\n# Giving an entrypoint so that we can append to it while running a container\nENTRYPOINT [\"composer\", \"--ignore-platform-reqs\"]\n\n```\n\nAnd then the compose part goes like this.\n```C\n  composer:\n    // Composer custom dockerfile which will be used to build image\n    build: \n      context: ./dockerFiles\n      dockerfile: composer.dockerfile\n    // Adding source code bind mount\n    volumes:\n      - ./src:/var/www/html\n\n```\nAdding a bind mount from src to /var/www/html so that we can have a mirror on host.\n\n\n### Artisan\n\nArtisan is another utility used in laravel development. Added it as well to make it available.\n\nThe compose part goes like this\n\n```C\n  artisan:\n    // Artisan can be built from the same php dockerfile\n    build: \n      context: ./dockerFiles\n      dockerfile: php.dockerfile\n    volumes:\n    // Adding source code bind mount to make source code available to it\n      - ./src:/var/www/html\n    // Adding a custom entry point so that we can execute artisan by appending specific commands while running.\n    entrypoint: [\"php\", \"/var/www/html/artisan\"]\n```\n\n### npm\n\nWe also have simple npm container in here which is required occassionally.\n\nIt is a straightforward npm setup.\n\nDocker compose for npm goes this way\n\n```C\n  npm:\n    // npm is build on top of node\n    image: node\n    // We set a working dir here itself\n    working_dir: /var/www/html/\n    // Entry point is npm as so that we can append any npm comamnd to docker run\n    entrypoint: [\"npm\"]\n    // Making source code available by bind mount\n    volumes:\n      - ./src:/var/www/html\n```\nI did not write a custom dockerfile for npm as it doesn't need anything more complex than just a working dir and entrypoint which are available in compose.\n\n## How To Use?\n\n1. Git clone\n2. Navigate into root of the project\n3. Run `docker-compose run --rm composer create-project laravel/laravel .`. This will setup a laravel project and will also reflect the same into src folder of your project.\n4. Edit the sr/.env file and add db configs\n5. Run `docker-compose up -d server`. Only server, as server depends on php and mysql and this commands thus starts php and mysql. **Note:** Add `--build` to check for changes in dockerfiles.\n\n### To Use Utility Containers Like Artisan\n\n1. Run `docker-compose run --rm artisan migrate`. You just add migrate at end as we have already given an entry point in docker compose file.\n\n\n## For Production\n\n1. In production as we don't have bind mounts, we have to have the source code in the image itself.\n2. For that, after development, you can replace dockerFiles folder with the prod/dockerFiles folder.\n3. Replace docker-compose.yaml file with prod/docker-compose.yaml\n4. These prod files remove bind mounts and copy the source code into the respective images.\n\nHope it help.\n\nDo star the repository if it does :-)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaiteja13427%2Fdocker-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaiteja13427%2Fdocker-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaiteja13427%2Fdocker-laravel/lists"}