Skip to content

Latest commit

 

History

History

.devcontainer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Dev Container

Running Dev Container

If you need/prefer the option you can build and use this template within a Dev Container, which you can run locally or with GitHub Codespaces.

To build and run locally you must first have docker and docker compose installed for your OS.

Once you have those installed you can click on the prompt:

image

Or by using the option in VSCode:

image image

Configuring Dev Container

After you click to run the app within a dev container you need to make sure your application .env is setup to use the proper configuration.

This means updating the following:

  1. Database Connection
  2. Mailer

The DB connection your .env should match the following:

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laranuxt
DB_USERNAME=root
DB_PASSWORD=password

And if you are using Mailhog as a development mail server:

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

These .env entires are important to update since the HOST must match what was configured in the dockerize'd environment. Otherwise your database and mail server will not get connected.

Dev Container Extras

To use tools like Spatie Ray you need to configure the dev container to do so.

First copy the ray.php file and add it to the root of this apps directory.

cp .devcontainer/ray.php ray.php

Next within your .env add the following entires:

Keep in mind the value RAY_LOCAL_PATH should be set to your machines full path to the app.

RAY_HOST=host.docker.internal
RAY_REMOTE_PATH=/workspace

# Set this to your working directory
RAY_LOCAL_PATH=/path/to/working/folder

Additional configuration

If you need to change any of the ports the dev container needs to map to you can add the following to your .env

DOCKER_PORT_MYSQL
DOCKER_PORT_MAILHOG_1
DOCKER_PORT_MAILHOG_2

Then set the value equal to the port you want it to run at.

For example if the mysql port of 3306 will not work for your locally, maybe you have another instance running.

You may set it to the value you want:

To run instead at port 13306

DOCKER_PORT_MYSQL=13306

After Dev Container Build

Once the Dev Container successfully built you can run your typically artisan/composer/yarn commands.

We suggest after everything is built opening up 2 integrated terminals.

To migrate and seed container database & To run API server

  1. One to run yarn seed && yarn api

To run Nuxt server

  1. yarn dev

But before both if this is the first time building the app you would still need to:

composer install && yarn install