{"id":18653294,"url":"https://github.com/secrethash/laravel-docker","last_synced_at":"2025-10-18T03:40:53.693Z","repository":{"id":204738580,"uuid":"712508301","full_name":"secrethash/laravel-docker","owner":"secrethash","description":"Docker repository for Laravel","archived":false,"fork":false,"pushed_at":"2023-12-17T18:32:39.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T14:09:23.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/secrethash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-10-31T15:53:40.000Z","updated_at":"2023-11-05T06:20:47.000Z","dependencies_parsed_at":"2024-11-07T07:11:10.255Z","dependency_job_id":"abbfe924-6efb-40ec-bb33-c6b41fc035e8","html_url":"https://github.com/secrethash/laravel-docker","commit_stats":null,"previous_names":["secrethash/laravel-docker"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secrethash%2Flaravel-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secrethash%2Flaravel-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secrethash%2Flaravel-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secrethash%2Flaravel-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/secrethash","download_url":"https://codeload.github.com/secrethash/laravel-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239466739,"owners_count":19643595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-07T07:11:02.928Z","updated_at":"2025-10-18T03:40:48.658Z","avatar_url":"https://github.com/secrethash.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker for Laravel on Local\r\n\r\nDocker Setup for Laravel applications for ***local development*** also supporting multi-tenancy using sub-domains (for ex: foo.localhost, bar.localhost). Tested with [Tenancy for Laravel](https://tenancyforlaravel.com/).\r\n\r\n\u003e ***WARNING:*** This setup is not recommended for production as-is.\r\n\r\n## Services Included\r\n\r\n- **PHP-FPM**\r\n- **NGINX** (server)\r\n- **TRAEFIK** (reverse proxy)\r\n- **SUPERVISOR** (process monitor)\r\n- **MySQL** (database)\r\n- **Redis** (key value database)\r\n- **Memcached** (caching)\r\n- **Meilisearch** (search driver for laravel scout)\r\n- **Mailhog** (email testing)\r\n- **Minio** (S3 on Local)\r\n\r\n## Steps to setup\r\n\r\n### Initial Setup\r\n\r\n1. Use this as a template Repository.\r\n2. Clone the created project from the template.\r\n    \u003e **NOTE:** For Windows users it is recommended to use it inside WSL.\r\n3. Create a `backend` and `frontend` folder inside the `workspace` directory.\r\n4. Copy this project's example.env as .env \u0026 update as required.\r\n5. Clone the backend (Laravel) app in your `backend` folder and frontend app in your `frontend` folder.\r\n    - Example: clone `backend` using ssh (on this project's root)\r\n\r\n    ```sh\r\n    git clone git@github.com:organization/backend-repo.git ./workspace/backend\r\n    ```\r\n\r\n    - Example: clone `frontend` using ssh (on this project's root)\r\n\r\n    ```sh\r\n    git clone git@github.com:organization/frontend-repo.git ./workspace/frontend\r\n    ```\r\n\r\n6. Edit the backend \u0026 frontend app's `.env` files according to your needs.\r\n    - Example `.env` values for Laravel Backend:\r\n\r\n        ```env\r\n        # Database\r\n        DB_CONNECTION=mysql\r\n        DB_HOST=mariadb\r\n        DB_PORT=3306\r\n        DB_DATABASE=laravel\r\n        DB_USERNAME=laravel\r\n        DB_PASSWORD=password\r\n\r\n        # Redis\r\n        REDIS_HOST=redis\r\n        REDIS_PASSWORD=null\r\n        REDIS_PORT=6379\r\n\r\n        # Mailer\r\n        MAIL_MAILER=smtp\r\n        MAIL_HOST=mailhog\r\n        MAIL_PORT=1025\r\n        MAIL_USERNAME=null\r\n        MAIL_PASSWORD=null\r\n        MAIL_ENCRYPTION=null\r\n\r\n        SCOUT_ELASTIC_HOST=\"meilisearch:7700\"\r\n        SCOUT_PREFIX=\r\n\r\n        # Filesystem\r\n        FILESYSTEM_DISK=s3\r\n        AWS_ACCESS_KEY_ID=laravel\r\n        AWS_SECRET_ACCESS_KEY=password\r\n        AWS_DEFAULT_REGION=us-east-1\r\n        # create the bucket if not created at:\r\n        # Minio Console: http://localhost:8900 \r\n        AWS_BUCKET=local\r\n        AWS_ENDPOINT=http://minio:9010\r\n        AWS_USE_PATH_STYLE_ENDPOINT=true\r\n        AWS_USE_PATH_STYLE_ENDPOINT_MEDIA=true\r\n        AWS_URL=http://localhost:9010/local # local refers to the name of the bucket\r\n        ```\r\n\r\n7. Run the docker up command with build \u0026 detached flag:\r\n\r\n    ```sh\r\n    docker compose up -d --build --remove-orphans\r\n    ```\r\n\r\n8. Enter the core container to:\r\n    - `composer install`\r\n    - setup laravel using:\r\n        - `php artisan key:generate`\r\n        - `php artisan migrate --seed`\r\n    - `yarn`\r\n\r\n    ```sh\r\n    docker exec -it shld-core sh\r\n    ```\r\n\r\n9. Re-create the Supervisor Worker:\r\n\r\n    ```sh\r\n    docker compose stop supervisor\r\n    docker compose rm supervisor\r\n    docker compose up -d\r\n    ```\r\n\r\n## Using AWS Signed URL uploads\r\n\r\nAWS supports creating a pre-signed url that can then be used to upload files to a specific predefined location, example: `tmp/`. Using this feature with minio as-is is not possible because when the `shld-core` core container listens to `http://minio:9010/*` it understands that the request is for the minio service's container. But when the `http://minio:9010/*` signed url is opened in your browser it doesn't know what this host is. For this we need to update the hosts file (generally located at `/etc/hosts` in linux) to understand `minio -\u003e 127.0.0.1`.\r\n\r\n- For Linux Users, edit the hosts file at `/etc/hosts` (you can run `sudo nano /etc/hosts` in terminal) and add this line:\r\n\r\n```sh\r\n127.0.0.1       minio\r\n```\r\n\r\n- For Mac Users, edit the hosts file located at `/private/etc/hosts` (you can run `sudo nano /private/etc/hosts` in your terminal) and add this line:\r\n\r\n```sh\r\n127.0.0.1       minio\r\n```\r\n\r\n- For Windows users it is recommended to use [PowerToys](https://learn.microsoft.com/en-us/windows/powertoys/). It includes a great [Hosts file editor](https://learn.microsoft.com/en-us/windows/powertoys/hosts-file-editor) tool for easier hosts editing.\r\n\r\n## Containers\r\n\r\n```sh\r\n[+] Running 10/10\r\n ✔ Network laravel-docker_shld   Created\r\n---- ⚓ Containers 👇 -----------------------\r\n ✔ Container shld-memcached      Started\r\n ✔ Container shld-elasticsearch  Started\r\n ✔ Container shld-redis          Started\r\n ✔ Container shld-db             Started\r\n ✔ Container shld-mailhog        Started\r\n ✔ Container shld-minio          Started\r\n ✔ Container shld-reverse-proxy  Started\r\n ✔ Container shld-core           Started\r\n ✔ Container shld-engine         Started\r\n ✔ Container shld-worker         Started\r\n```\r\n\r\n## Starting and stopping\r\n\r\nAfter the initial setup:\r\n\r\n1. To bring the containers down you just need to run the following command:\r\n\r\n    ```sh\r\n    docker compose down\r\n    ```\r\n\r\n2. If you want to bring them up, just run:\r\n\r\n    ```sh\r\n    docker compose up -d --remove-orphans\r\n    ```\r\n\r\n3. To enter the core container's shell to run `composer`, `yarn` \u0026 `php artisan` based commands:\r\n\r\n    ```sh\r\n    docker exec -it shld-core sh\r\n    ```\r\n\r\n## Access URLs\r\n\r\n1. **Application:**\r\n    - URL Scheme: `{APP_HOST}:{FORWARD_TRAEFIK_PORT}`\r\n    - Example: `http://localhost`\r\n\r\n2. **Minio Console:**\r\n    - URL Scheme: `{MINIO_HOST}:{FORWARD_MINIO_CONSOLE_PORT}`\r\n    - Example: `http://localhost:8900`\r\n\r\n3. **MailHog Dashboard:**\r\n    - URL Scheme: `{APP_HOST}:{FORWARD_MAILHOG_DASHBOARD_PORT}`\r\n    - Example: `http://localhost:8025`\r\n\r\n4. **Traefik Dashboard:**\r\n    - URL Scheme: `{TRAEFIK_DASH}:{FORWARD_TRAEFIK_DASH_PORT}/dashboard`\r\n    - Example: `http://localhost:8080/dashboard`\r\n\r\n## Importing Database from dumps\r\n\r\nWe bind mount `./dumps` folder to mariadb instance at `/mysql-dumps` so it's always accessible for importing database. To import a database dump, just follow the following process:\r\n\r\n1. Put the dump to be imported in `./dumps` folder.\r\n2. Enter the `db` container instance:\r\n\r\n    ```sh\r\n    docker exec -it marketplace2-db bash\r\n    ```\r\n\r\n    OR using [shld CLI](#use-shld-command-linux)\r\n\r\n    ```sh\r\n    jpt db bash\r\n    ```\r\n\r\n3. Import DB using `mariadb` command `mariadb -u [DB_USERNAME] -p [DB_DATABASE]`, replacing `{NAME_OF_YOUR_DUMP}` with the name of the dump you copied to `./dump` folder (make sure it's in .sql file format):\r\n\r\n    ```sh\r\n    mariadb -u laravel -p laravel \u003c /mysql-dumps/{NAME_OF_YOUR_DUMP}\r\n    ```\r\n\r\n    to import a `.sql.gzip` file:\r\n\r\n    ```sh\r\n    gunzip \u003c /mysql-dumps/{NAME_OF_YOUR_DUMP}.sql.gz | mariadb -u laravel -p laravel\r\n    ```\r\n\r\n## Use `shld` Command (linux)\r\n\r\n\u003e **Note:** This also works with WSL linux. This might also work on MacOS (not tested)\r\n\r\nInstead of going inside the container interactively every time, then running the desired command, You can use command `shld` to run commands directly:\r\n\r\n```sh\r\nshld core artisan about\r\n# OR\r\nshld core composer install\r\n# OR\r\nshld core yarn\r\n```\r\n\r\nWhere `core` is the container (i.e. `shld-core`) followed by the command that you want to run on that container.\r\n\r\nTo achieve this you need to setup the shld command first:\r\n\r\n1. make `shld_command.sh` executable\r\n\r\n    ```sh\r\n    chmod +x ./shld_command.sh\r\n    ```\r\n\r\n2. Add source to the bash (if using zsh or anything other than bash, replace the `.bashrc` with the correct one):\r\n\r\n    ```sh\r\n    echo -e \"\\n# SHLD Command\\nsource $PWD/shld_command.sh\" \u003e\u003e ~/.bashrc\r\n    source ~/.bashrc\r\n    ```\r\n\r\n### Commands\r\n\r\nTo run these basic commands (below) inside the `core` container you don't need to specify `core` in the command, they can be executed directly. To run them in a different container, you will have to specify a container.\r\n\r\n#### Example (on core container)\r\n\r\n```sh\r\nshld core artisan about\r\n```\r\n\r\nSo this would also work, and acts as a shorthand:\r\n\r\n```sh\r\nshld artisan about\r\n```\r\n\r\n#### Example (on supervisor container)\r\n\r\n\u003e Note: Although it's an option, it won't be needed for most use cases.\r\n\r\n```sh\r\nshld worker artisan about\r\n```\r\n\r\n1. Docker compose up\r\n\r\n    Proxies: `docker compose up -d --build --remove-orphans`\r\n\r\n    ```sh\r\n    shld up -b\r\n    ```\r\n\r\n2. Docker compose down\r\n\r\n    Proxies: `docker compose down`\r\n\r\n    ```sh\r\n    shld down\r\n    ```\r\n\r\n3. PHP Artisan Commands\r\n\r\n    Proxies: `docker compose -it exec shld-core php artisan about`\r\n\r\n    ```sh\r\n    shld artisan about\r\n    ```\r\n\r\n4. Tinker Command\r\n\r\n    Proxies: `docker compose -it exec shld-core php artisan tinker`\r\n\r\n    ```sh\r\n    shld tinker\r\n    ```\r\n\r\n5. Composer Commands\r\n\r\n    Proxies: `docker compose -it exec shld-core composer install`\r\n\r\n    ```sh\r\n    shld composer install\r\n    ```\r\n\r\n6. Yarn Commands\r\n\r\n    Proxies: `docker compose -it exec shld-core yarn`\r\n\r\n    ```sh\r\n    shld yarn\r\n    ```\r\n\r\n    Proxies: `docker compose -it exec shld-core yarn dev`\r\n\r\n    ```sh\r\n    shld yarn dev\r\n    ```\r\n\r\n    \u003e **Note:** The supervisor (worker) container already keep an instance on `yarn dev` running. You can control that in `.env` config.\r\n\r\n7. PHP Unit\r\n\r\n    Proxies: `docker compose -it exec shld-core ./vendor/bin/phpunit`\r\n\r\n    ```sh\r\n    shld unit\r\n    ```\r\n\r\n    OR\r\n\r\n    ```sh\r\n    shld phpunit\r\n    ```\r\n\r\n8. Pint\r\n\r\n    Proxies: `docker compose -it exec shld-core ./vendor/bin/pint`\r\n\r\n    ```sh\r\n    shld pint\r\n    ```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecrethash%2Flaravel-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecrethash%2Flaravel-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecrethash%2Flaravel-docker/lists"}