Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melhora configuração do Docker #982

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ Clone o repositório:
git clone [email protected]:portabilis/i-educar.git && cd i-educar
```

Copie o arquivo `docker-compose.example.yml` e faça as configurações para o seu ambiente:

```bash
cp docker-compose.example.yml docker-compose.override.yml
```

Faça o build das imagens Docker utilizadas no projeto e inicie os containers da aplicação (pode levar alguns minutos):

```bash
Expand All @@ -60,8 +54,8 @@ docker-compose exec php artisan db:seed

### Personalizando a instalação

No arquivo `docker-compose.override.yml` você pode personalizar sua instalação do i-Educar, mudando as portas dos
serviços ou o mapeamento dos volumes da aplicação.
Você pode criar o arquivo `docker-compose.override.yml` para personalizar sua instalação do i-Educar, mudando as portas
dos serviços ou o mapeamento dos volumes.

### Xdebug

Expand Down
46 changes: 10 additions & 36 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,16 @@ composer plug-and-play:update
Sua instalação estará atualizada e você poderá realizar seu
[primeiro acesso](https://github.com/portabilis/i-educar#primeiro-acesso) na nova versão do i-Educar.

### Configurar ambiente com Docker
### Personalizar o ambiente com Docker

Na versão [2.9](https://github.com/portabilis/i-educar/tree/2.9) o arquivo `docker-compose.yml` não expõem nenhuma porta
dos containers para evitar conflitos. Para isso, utilize o arquivo `docker-compose.override.yml` e configure quais
portas deseja que os serviços sejam executados.
Na versão [2.9](https://github.com/portabilis/i-educar/tree/2.9) o arquivo `docker-compose.yml` utiliza variáveis de
ambiente para expor as portas dos containers. Você pode adicionar no seu arquivo `.env`:

```bash
cp docker-compose.example.yml docker-compose.override.yml
```
| Variável | Descrição |
|-------------------------|---------------------------|
| `DOCKER_NGINX_PORT` | Porta HTTP da aplicação |
| `DOCKER_NGINX_SSL_PORT` | Porta HTTPS da aplicação |
| `DOCKER_POSTGRES_PORT` | Porta do banco de Dados |
| `DOCKER_REDIS_PORT` | Porta do serviço de cache |

#### Arquivo de exemplo de configuração do `docker-compose.override.yml`

O exemplo abaixo possui configurações básicas que podem ser customizadas e que não irão interferir no código fonte
original do projeto permitindo assim um maior controle do seu ambiente.

```yml
services:

php:
container_name: ieducar-php
volumes:
- ~/.ssh:/root/.ssh:ro # permite conexões usando suas chaves SSH

nginx:
container_name: ieducar-nginx
ports:
- "80:80" # permite acessar o i-Educar em http://localhost, ou
- "8000:80" # permite acessar o i-Educar em http://localhost:8080

postgres:
container_name: ieducar-postgres
ports:
- "5432:5432" # permite conectar software gerenciador de banco de dados

redis:
container_name: ieducar-redis
ports:
- "6379:6379" # permite conectar software gerenciador de banco de dados
```
Você também pode utilizar o arquivo `docker-compose.override.yml` para mais configurações.
13 changes: 0 additions & 13 deletions docker-compose.example.yml

This file was deleted.

13 changes: 12 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ services:

php:
container_name: ieducar-php
build: docker/php
build:
context: docker/php
args:
PHP_VERSION: 8.3
COMPOSER_VERSION: 2.7
links:
- postgres
- redis
Expand All @@ -24,6 +28,9 @@ services:
volumes:
- ./:/var/www/ieducar
- ./docker/nginx:/etc/nginx/conf.d/
ports:
- ${DOCKER_NGINX_PORT:-80}:80
- ${DOCKER_NGINX_SSL_PORT:-443}:443

postgres:
container_name: ieducar-postgres
Expand All @@ -34,11 +41,15 @@ services:
POSTGRES_PASSWORD: ieducar
volumes:
- postgres:/var/lib/postgresql/data
ports:
- ${DOCKER_POSTGRES_PORT:-5432}:5432

redis:
container_name: ieducar-redis
image: redis:7-alpine
restart: always
ports:
- ${DOCKER_REDIS_PORT:-6379}:6379

volumes:
postgres:
7 changes: 5 additions & 2 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM composer:2.7 as composer
FROM php:8.3-fpm-alpine
ARG PHP_VERSION=8
ARG COMPOSER_VERSION=latest

FROM composer:${COMPOSER_VERSION} AS composer
FROM php:${PHP_VERSION}-fpm-alpine

COPY --from=composer /usr/bin/composer /usr/local/bin/composer

Expand Down
3 changes: 1 addition & 2 deletions tests/Api/EmployeeCreatedEventTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

namespace Api;
namespace Tests\Api;

use App\Events\EmployeeCreated;
use Database\Factories\LegacyIndividualFactory;
use Database\Factories\LegacyUserFactory;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Event;
use Tests\Api\DiarioApiRequestTestTrait;
use Tests\TestCase;

class EmployeeCreatedEventTest extends TestCase
Expand Down
3 changes: 1 addition & 2 deletions tests/Api/StudentCreatedEventTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

namespace Api;
namespace Tests\Api;

use App\Events\StudentCreated;
use Database\Factories\LegacyIndividualFactory;
use Database\Factories\LegacyMaritalStatusFactory;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Event;
use Tests\Api\DiarioApiRequestTestTrait;
use Tests\TestCase;

class StudentCreatedEventTest extends TestCase
Expand Down
Loading