- Docker
- mkcert
Clone this repository
git clone https://github.com/maxcelos/laravel-docker-compose.git
cd laravel-docker-composeOpen it in your IDE, search for lscore in all files and replace it with the name of your app, for example myapp.
Copy all content of this repository in the root of your Laravel project
Now in the root folder of your project, follow the steps below:
Copy .env
cp .env.example .envGenerate SSL certificates
Replace
lscorein the command below with the name of your app, for examplemyapp.
mkcert -cert-file docker/nginx/ssl/app-cert.pem -key-file docker/nginx/ssl/app-key.pem "*.lscore.localhost" "lscore.localhost"Build docker images
docker compose buildStart containers
docker compose up -dInstall PHP dependencies
make composer installInstall Node dependencies
make pnpm installGenerate key
make artisan key:generateRun database migration
make migrateUpdate your vite.config.js, adding the section below in your defineConfig:
Replace
lscorewith your app name, for examplemyapp.
server: {
host: "0.0.0.0",
port: 5173,
cors: true,
strictPort: true,
https: {
key: fs.readFileSync(path.resolve(__dirname, 'docker/nginx/ssl/app-key.pem')),
cert: fs.readFileSync(path.resolve(__dirname, 'docker/nginx/ssl/app-cert.pem')),
},
hmr: {
host: "lscore.localhost",
},
},Start the application
make startThis will run
composer devcommand inside the container
Done.
The app should be available in https://myapp.localhost
If containers are up you can always access the app. The
startcommand will run the hot-reload and queues.
The docker compose includes and instance of Web PgAdmin. Use the credentials below to easily access database.
URL: http://localhost:8081 Username: [email protected] Password: password
In the first access, you need to set up the connection. Follow the steps below
Right click in "Servers" > "Register"
In the "General" tab, set a name (any) for your server.
In the "Connection" tab, set the hostname as "postgres", and database, username and password will be the values from your .env. If you use the .env.example, it will be "myapp" for all.
O SonarQube é uma plataforma de código aberto para análise contínua da qualidade do código. Ele permite identificar bugs, vulnerabilidades, code smells e problemas de segurança, ajudando equipes de desenvolvimento a manterem um código limpo, seguro e sustentável.
Entre com as credenciais abaixo e será solicitado uma nova senha:
- Usuário:
admin - Senha:
admin
Após o login, gere um Token do tipo Global para poder utilizar no scan das aplicações.
- Acesse o menu superior direito, no ícone do usuário Admin.
- Clique em My Account e em seguida na aba Security.
- Em Generate Tokens, dê um nome ao token ex:
CICD, escolha tipo Global e sua expiração. - Copie o token gerado e cole no arquivo
./docker/scripts/sonarscan.shna linha 4.
Configure a execução dos testes para que gere o arquivo de coverage, o comando make sonarqube faz o fluxo para execução do testes e do scan do código.
Para que os testes consiga gerar o coverage, é necessário a instalação do pacote pcov no container docker.
O scan irá enviar ao sonarqube o arquivo de coverage gerado para que possa visualizar a cobertura corretamente do código.