|
| 1 | +--- |
| 2 | +description: >- |
| 3 | + Create a containerized development environment so you can build, test and |
| 4 | + contribute to Speedtest Tracker. |
| 5 | +--- |
| 6 | + |
| 7 | +# Setup Your Environment |
| 8 | + |
| 9 | +Speedtest Tracker is built on the [Laravel](https://laravel.com/) framework, this means we get to use some awesome 1st party packages like [Laravel Sail](https://laravel.com/docs/9.x/sail) to create a local containerized development environment. |
| 10 | + |
| 11 | +These directions will walk you through the steps of setting up that environment. |
| 12 | + |
| 13 | +{% hint style="info" %} |
| 14 | +These directions assume you have a working knowledge of the Laravel framework. If you have questions on how to use it the [Laravel Docs](https://laravel.com/docs/9.x) and [Laracasts series](https://laracasts.com/series/laravel-8-from-scratch) on "Laravel from Scratch" are a good place to start. |
| 15 | +{% endhint %} |
| 16 | + |
| 17 | +### 1. Clone the repository |
| 18 | + |
| 19 | +First let's clone the [repository](https://github.com/alexjustesen/speedtest-tracker) to your machine, I prefer [GitHub's CLI](https://cli.github.com/) so that command is included below. |
| 20 | + |
| 21 | +```bash |
| 22 | +gh repo clone alexjustesen/speedtest-tracker \ |
| 23 | + && cd speedtest-tracker |
| 24 | +``` |
| 25 | + |
| 26 | +### 2. Make a copy of \`.env.example\` and update DB variables |
| 27 | + |
| 28 | +Next we need to make a copy of `.env.example`, the environment file is what Laravel uses. |
| 29 | + |
| 30 | +```bash |
| 31 | +cp .env.example .env |
| 32 | +``` |
| 33 | + |
| 34 | +You'll also want to fill in a few `DB_` variables here as well which will control which database Laravel will use. I've included PostgreSQL as the default database system. |
| 35 | + |
| 36 | +``` |
| 37 | +DB_CONNECTION=pgsql |
| 38 | +DB_HOST=pgsql |
| 39 | +DB_PORT=5432 |
| 40 | +DB_DATABASE=speedtest_tracker |
| 41 | +DB_USERNAME=sail |
| 42 | +DB_PASSWORD=password |
| 43 | +``` |
| 44 | + |
| 45 | +### 3. Install Composer dependencies |
| 46 | + |
| 47 | +We'll use a temporary container to install the Composer dependencies for the application. |
| 48 | + |
| 49 | +```bash |
| 50 | +docker run --rm \ |
| 51 | + -u "$(id -u):$(id -g)" \ |
| 52 | + -v $(pwd):/var/www/html \ |
| 53 | + -w /var/www/html \ |
| 54 | + laravelsail/php81-composer:latest \ |
| 55 | + composer install --ignore-platform-reqs |
| 56 | +``` |
| 57 | + |
| 58 | +### 4. Starting a development environment |
| 59 | + |
| 60 | +To start up the environment we can now use the Sail binary that is included with the package to build our development image and spin up a network with a database container. |
| 61 | + |
| 62 | +```bash |
| 63 | +./vendor/bin/sail up -d |
| 64 | + |
| 65 | +# or if you have a Sail alias setup.. |
| 66 | +sail up -d |
| 67 | +``` |
| 68 | + |
| 69 | +### 5. Stopping the development environment |
| 70 | + |
| 71 | +```bash |
| 72 | +./vendor/bin/sail down |
| 73 | + |
| 74 | +# or if you have a Sail alias setup.. |
| 75 | +sail down |
| 76 | +``` |
0 commit comments