Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sschonss/tutorial-docker-laravel-mariadb
https://github.com/sschonss/tutorial-docker-laravel-mariadb
Last synced: 26 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sschonss/tutorial-docker-laravel-mariadb
- Owner: sschonss
- Created: 2023-05-12T13:11:11.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-16T16:14:42.000Z (over 1 year ago)
- Last Synced: 2024-11-13T02:13:37.618Z (3 months ago)
- Language: PHP
- Size: 84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Docker & Laravel
## _Laravel + MariaDB_
---# Introduction :page_facing_up:
This tutorial will help you to create a Laravel project using Docker.
My goal is to help you to create a Laravel project using Docker in a simple way.
I decided to write this tutorial because I had some difficulties to create a Laravel project using Docker and I want to help you to avoid these difficulties.
Flowing a documentation is a good way to learn, but sometimes you need to read a tutorial to understand it better.
However, I learned a lot of writing this tutorial, so it is a win-win situation.
If you have any questions, you can contact me on [LinkedIn](https://www.linkedin.com/in/luiz-schons/) or [GitHub](https://github.com/sschonss).
>That is my first tutorial in English, sorry for any mistakes.
---
# Installation :whale:## Docker
- [Docker](https://docs.docker.com/get-docker/)For Windows, you need to install [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install-win10) and [Docker Desktop](https://docs.docker.com/docker-for-windows/install/)
## Docker Compose
- [Docker Compose](https://docs.docker.com/compose/install/)
---# Usage :rocket:
## Clone the docker-compose.yml file
```sh
mkdir ~/myapp && cd ~/myapp
curl -LO https://raw.githubusercontent.com/bitnami/containers/main/bitnami/laravel/docker-compose.yml
```## Attention :warning:
You need to change environment variables in the docker-compose.yml file to your own values.
Sometimes, you need to change the ports in the docker-compose.yml file to avoid conflicts with other services.
Maybe you need to open your project `~/myapp` in your IDE or text editor to edit your .env file.
Remember to change the DB_HOST variable in your .env file to the name of the service defined in the docker-compose.yml file.
It can be necessary to change permissions of the `~/myapp` directory, because the container will create files in this directory, and maybe you can't edit these files.
## Start the services :muscle:
```sh
docker-compose up
```One tip: You can use the -d flag to run the containers in the background:
```sh
docker-compose up -d
```I recommend you don't use the -d flag when you start the containers for the first time, because you can see the logs of the containers and check if everything is working correctly.
## Stop the services :stop_sign:
```sh
docker-compose down
```## Tips :bulb:
### Check the status of the containers
```sh
docker-compose ps
```### Check the logs of the containers
```sh
docker-compose logs
```### Check the logs of a specific container
```sh
docker-compose logs
```### Check the logs of a specific container in real time
```sh
docker-compose logs -f
```## Access the application :computer:
In your terminal, you can see the URL of your application.
Normally, the URL is http://localhost:8000 if you don't change the ports in the docker-compose.yml file.
## Access the database :floppy_disk:
I recommend you use [DBeaver](https://dbeaver.io/) or [DataGrip](https://www.jetbrains.com/datagrip/) to access the database.
You can use the credentials defined in the docker-compose.yml file.
## Access the container :package:
You can access the container using the following command:
```sh
docker-compose exec bash
```If you use Windows, you can open Docker Desktop and click in the container name to open a terminal.
## Final considerations :memo:
I recommend you read the [Bitnami Laravel](https://hub.docker.com/r/bitnami/laravel/) documentation to learn more about this image.
You can use this [Bitnami Laravel](https://hub.docker.com/r/bitnami/laravel/) image in production, but you need to change the environment variables in the docker-compose.yml file to your own values.
I wrote this tutorial to help you, but I don't know everything about Docker and Laravel, I'm learning too.
I hope this tutorial helps you. :smile:
[LinkedIn](https://www.linkedin.com/in/luiz-schons/)
[GitHub](https://github.com/sschonss)---