#48 - deployment #68

Merged
Baakoma merged 9 commits from #48-deployment into main 2022-03-04 14:47:45 +01:00
8 changed files with 115 additions and 52 deletions
Showing only changes of commit 697f3395bd - Show all commits

View File

@@ -9,31 +9,34 @@ LOG_LEVEL=debug
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=toby-db-dev DB_HOST=toby-db-dev
DB_PORT=3306 DB_PORT=5432
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
DB_DATABASE=toby DB_DATABASE=toby
DB_USERNAME=toby DB_USERNAME=toby
mtracz commented 2022-03-04 11:08:56 +01:00 (Migrated from github.com)
Review

I didn't notice that there is a default value in docker-compose.yml. So let's make them consistent, and please set 80 in .env file.

ports:
      - ${EXTERNAL_WEBSERVER_PORT:-80}:80
I didn't notice that there is a default value in docker-compose.yml. So let's make them consistent, and please set 80 in .env file. ``` ports: - ${EXTERNAL_WEBSERVER_PORT:-80}:80 ```
DB_PASSWORD=password DB_PASSWORD=password
DB_ROOT_PASSWORD=example DB_ROOT_PASSWORD=example
DOCKER_DEV_DB_EXTERNAL_PORT=3306 DOCKER_DEV_DB_EXTERNAL_PORT=5432
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
DOCKER_DEV_DB_DATABASE=${DB_DATABASE} DOCKER_DEV_DB_DATABASE=${DB_DATABASE}
DOCKER_DEV_DB_USERNAME=${DB_USERNAME} DOCKER_DEV_DB_USERNAME=${DB_USERNAME}
DOCKER_DEV_DB_PASSWORD=${DB_PASSWORD} DOCKER_DEV_DB_PASSWORD=${DB_PASSWORD}
DOCKER_DEV_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD} DOCKER_DEV_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
DOCKER_TEST_DB_EXTERNAL_PORT=3307 DOCKER_TEST_DB_EXTERNAL_PORT=5433
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
DOCKER_TEST_DB_DATABASE=${DB_DATABASE} DOCKER_TEST_DB_DATABASE=${DB_DATABASE}
DOCKER_TEST_DB_USERNAME=${DB_USERNAME} DOCKER_TEST_DB_USERNAME=${DB_USERNAME}
DOCKER_TEST_DB_PASSWORD=${DB_PASSWORD} DOCKER_TEST_DB_PASSWORD=${DB_PASSWORD}
DOCKER_TEST_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD} DOCKER_TEST_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
REDIS_PORT=6379
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
REDIS_HOST=toby-redis
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
EXTERNAL_WEBSERVER_PORT= EXTERNAL_WEBSERVER_PORT=
XDG_CONFIG_HOME=/tmp XDG_CONFIG_HOME=/tmp
mtracz commented 2022-03-04 09:54:12 +01:00 (Migrated from github.com)
Review

Maybe it will be good to create separate env_file for docker-compose config?

Maybe it will be good to create separate `env_file` for docker-compose config?
Baakoma commented 2022-03-04 10:11:56 +01:00 (Migrated from github.com)
Review

Separate env file only for docker-related config? What if we have the same variables in app and docker?

Separate `env file` only for docker-related config? What if we have the same variables in app and docker?
mtracz commented 2022-03-04 11:19:04 +01:00 (Migrated from github.com)
Review

I thought about move all variables related to docker-compose substitution (docker-compose use shell variables and then variables from .env file). There cannot be multiple .env files for building docker-compose config.

We can specify env_files param in each service but then all variables from provided file will be injected into service container. That wont help us with this problem about multiple docker variables in .env file.

I thought about move all variables related to docker-compose substitution (docker-compose use shell variables and then variables from .env file). There cannot be multiple .env files for building docker-compose config. We can specify `env_files` param in each service but then all variables from provided file will be injected into service container. That wont help us with this problem about multiple docker variables in `.env` file.
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
CACHE_DRIVER=file CACHE_DRIVER=file
QUEUE_CONNECTION=sync QUEUE_CONNECTION=sync
SESSION_DRIVER=file SESSION_DRIVER=redis
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
SESSION_LIFETIME=120 SESSION_LIFETIME=120
FILESYSTEM_DISK=local FILESYSTEM_DISK=local
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```
mtracz commented 2022-03-04 09:50:19 +01:00 (Migrated from github.com)
Review
APP_NAME="Toby HR application"
```suggestion APP_NAME="Toby HR application" ```

View File

@@ -21,6 +21,11 @@ return [
"driver" => "file", "driver" => "file",
"path" => storage_path("framework/cache/data"), "path" => storage_path("framework/cache/data"),
], ],
"redis" => [
"driver" => "redis",
"connection" => "cache",
"lock_connection" => "default",
],
], ],
"prefix" => env("CACHE_PREFIX", Str::slug(env("APP_NAME", "laravel"), "_") . "_cache"), "prefix" => env("CACHE_PREFIX", Str::slug(env("APP_NAME", "laravel"), "_") . "_cache"),
]; ];

View File

@@ -2,23 +2,46 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Support\Str;
return [ return [
"default" => env("DB_CONNECTION", "mysql"), "default" => env("DB_CONNECTION", "mysql"),
"connections" => [ "connections" => [
'pgsql' => [ "pgsql" => [
'driver' => 'pgsql', "driver" => "pgsql",
'url' => env('DATABASE_URL'), "url" => env("DATABASE_URL"),
'host' => env('DB_HOST', '127.0.0.1'), "host" => env("DB_HOST", "127.0.0.1"),
'port' => env('DB_PORT', '5432'), "port" => env("DB_PORT", "5432"),
'database' => env('DB_DATABASE', 'forge'), "database" => env("DB_DATABASE", "forge"),
'username' => env('DB_USERNAME', 'forge'), "username" => env("DB_USERNAME", "forge"),
'password' => env('DB_PASSWORD', ''), "password" => env("DB_PASSWORD", ""),
'charset' => 'utf8', "charset" => "utf8",
'prefix' => '', "prefix" => "",
'prefix_indexes' => true, "prefix_indexes" => true,
'search_path' => 'public', "search_path" => "public",
'sslmode' => 'prefer', "sslmode" => "prefer",
], ],
], ],
"migrations" => "migrations", "migrations" => "migrations",
"redis" => [
"client" => env("REDIS_CLIENT", "phpredis"),
"options" => [
"cluster" => env("REDIS_CLUSTER", "redis"),
"prefix" => env("REDIS_PREFIX", Str::slug(env("APP_NAME", "laravel"), "_") . "_database_"),
],
"default" => [
"url" => env("REDIS_URL"),
"host" => env("REDIS_HOST", "127.0.0.1"),
"password" => env("REDIS_PASSWORD"),
"port" => env("REDIS_PORT", "6379"),
"database" => env("REDIS_DB", "0"),
],
"cache" => [
"url" => env("REDIS_URL"),
"host" => env("REDIS_HOST", "127.0.0.1"),
"password" => env("REDIS_PASSWORD"),
"port" => env("REDIS_PORT", "6379"),
"database" => env("REDIS_CACHE_DB", "1"),
],
],
]; ];

View File

@@ -8,6 +8,14 @@ return [
"sync" => [ "sync" => [
"driver" => "sync", "driver" => "sync",
], ],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
'after_commit' => false,
],
], ],
"failed" => [ "failed" => [
"driver" => env("QUEUE_FAILED_DRIVER", "database-uuids"), "driver" => env("QUEUE_FAILED_DRIVER", "database-uuids"),

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Database\Factories; namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use Toby\Domain\Enums\VacationRequestState; use Toby\Domain\States\VacationRequest\VacationRequestState;
use Toby\Eloquent\Models\VacationRequestActivity; use Toby\Eloquent\Models\VacationRequestActivity;
class VacationRequestActivityFactory extends Factory class VacationRequestActivityFactory extends Factory
@@ -15,8 +15,8 @@ class VacationRequestActivityFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
"from" => $this->faker->randomElement(VacationRequestState::cases()), "from" => $this->faker->randomElement(VacationRequestState::all()),
"to" => $this->faker->randomElement(VacationRequestState::cases()), "to" => $this->faker->randomElement(VacationRequestState::all()),
]; ];
} }
} }

View File

@@ -10,9 +10,15 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Toby\Domain\Enums\EmploymentForm; use Toby\Domain\Enums\EmploymentForm;
use Toby\Domain\Enums\Role; use Toby\Domain\Enums\Role;
use Toby\Domain\Enums\VacationRequestState;
use Toby\Domain\Enums\VacationType; use Toby\Domain\Enums\VacationType;
use Toby\Domain\PolishHolidaysRetriever; use Toby\Domain\PolishHolidaysRetriever;
use Toby\Domain\States\VacationRequest\AcceptedByAdministrative;
use Toby\Domain\States\VacationRequest\AcceptedByTechnical;
use Toby\Domain\States\VacationRequest\Approved;
use Toby\Domain\States\VacationRequest\Created;
use Toby\Domain\States\VacationRequest\Rejected;
use Toby\Domain\States\VacationRequest\WaitingForAdministrative;
use Toby\Domain\States\VacationRequest\WaitingForTechnical;
use Toby\Domain\VacationDaysCalculator; use Toby\Domain\VacationDaysCalculator;
use Toby\Eloquent\Helpers\UserAvatarGenerator; use Toby\Eloquent\Helpers\UserAvatarGenerator;
use Toby\Eloquent\Models\User; use Toby\Eloquent\Models\User;
@@ -148,7 +154,7 @@ class DemoSeeder extends Seeder
/** @var VacationRequest $vacationRequestApproved */ /** @var VacationRequest $vacationRequestApproved */
$vacationRequestApproved = VacationRequest::factory([ $vacationRequestApproved = VacationRequest::factory([
"type" => VacationType::Vacation->value, "type" => VacationType::Vacation->value,
"state" => VacationRequestState::Created, "state" => Created::class,
"from" => Carbon::create($currentYearPeriod->year, 1, 31)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 1, 31)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Komentarz do wniosku urlopowego.", "comment" => "Komentarz do wniosku urlopowego.",
@@ -175,49 +181,50 @@ class DemoSeeder extends Seeder
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => null, "from" => null,
"to" => VacationRequestState::Created, "to" => Created::class,
])->for($vacationRequestApproved) ])->for($vacationRequestApproved)
->for($employee1) ->for($employee1)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::Created, "from" => Created::class,
"to" => VacationRequestState::WaitingForTechnical, "to" => WaitingForTechnical::class,
])->for($vacationRequestApproved) ])->for($vacationRequestApproved)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::WaitingForTechnical, "from" => WaitingForTechnical::class,
"to" => VacationRequestState::AcceptedByTechnical, "to" => AcceptedByTechnical::class,
])->for($vacationRequestApproved) ])->for($vacationRequestApproved)
->for($technicalApprover) ->for($technicalApprover)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::AcceptedByTechnical, "from" => AcceptedByTechnical::class,
"to" => VacationRequestState::WaitingForAdministrative, "to" => WaitingForAdministrative::class,
])->for($vacationRequestApproved) ])->for($vacationRequestApproved)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::WaitingForAdministrative, "from" => WaitingForAdministrative::class,
"to" => VacationRequestState::AcceptedByAdministrative, "to" => AcceptedByAdministrative::class,
])->for($vacationRequestApproved) ])->for($vacationRequestApproved)
->for($administrativeApprover) ->for($administrativeApprover)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::AcceptedByAdministrative, "from" => AcceptedByAdministrative::class,
"to" => VacationRequestState::Approved, "to" => Approved::class,
])->for($vacationRequestApproved) ])->for($vacationRequestApproved)
->create(); ->create();
$vacationRequestApproved->changeStateTo(VacationRequestState::Approved); $vacationRequestApproved->state = new Approved($vacationRequestApproved);
$vacationRequestApproved->save();
/** @var VacationRequest $vacationRequestWaitsForAdminApproval */ /** @var VacationRequest $vacationRequestWaitsForAdminApproval */
$vacationRequestWaitsForAdminApproval = VacationRequest::factory([ $vacationRequestWaitsForAdminApproval = VacationRequest::factory([
"type" => VacationType::Vacation->value, "type" => VacationType::Vacation->value,
"state" => VacationRequestState::Created, "state" => Created::class,
"from" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(),
"comment" => "Komentarz do wniosku urlopowego.", "comment" => "Komentarz do wniosku urlopowego.",
@@ -244,36 +251,37 @@ class DemoSeeder extends Seeder
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => null, "from" => null,
"to" => VacationRequestState::Created, "to" => Created::class,
])->for($vacationRequestWaitsForAdminApproval) ])->for($vacationRequestWaitsForAdminApproval)
->for($employee1) ->for($employee1)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::Created, "from" => Created::class,
"to" => VacationRequestState::WaitingForTechnical, "to" => WaitingForTechnical::class,
])->for($vacationRequestWaitsForAdminApproval) ])->for($vacationRequestWaitsForAdminApproval)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::WaitingForTechnical, "from" => WaitingForTechnical::class,
"to" => VacationRequestState::AcceptedByTechnical, "to" => AcceptedByTechnical::class,
])->for($vacationRequestWaitsForAdminApproval) ])->for($vacationRequestWaitsForAdminApproval)
->for($technicalApprover) ->for($technicalApprover)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::AcceptedByTechnical, "from" => AcceptedByTechnical::class,
"to" => VacationRequestState::WaitingForAdministrative, "to" => WaitingForAdministrative::class,
])->for($vacationRequestWaitsForAdminApproval) ])->for($vacationRequestWaitsForAdminApproval)
->create(); ->create();
$vacationRequestWaitsForAdminApproval->changeStateTo(VacationRequestState::WaitingForAdministrative); $vacationRequestWaitsForAdminApproval->state = new WaitingForAdministrative($vacationRequestWaitsForAdminApproval);
$vacationRequestWaitsForAdminApproval->save();
/** @var VacationRequest $vacationRequestRejected */ /** @var VacationRequest $vacationRequestRejected */
$vacationRequestRejected = VacationRequest::factory([ $vacationRequestRejected = VacationRequest::factory([
"type" => VacationType::Vacation->value, "type" => VacationType::Vacation->value,
"state" => VacationRequestState::Created, "state" => Created::class,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"comment" => "", "comment" => "",
@@ -300,25 +308,26 @@ class DemoSeeder extends Seeder
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => null, "from" => null,
"to" => VacationRequestState::Created, "to" => Created::class,
])->for($vacationRequestRejected) ])->for($vacationRequestRejected)
->for($employee1) ->for($employee1)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::Created, "from" => Created::class,
"to" => VacationRequestState::WaitingForTechnical, "to" => WaitingForTechnical::class,
])->for($vacationRequestRejected) ])->for($vacationRequestRejected)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
"from" => VacationRequestState::WaitingForTechnical, "from" => WaitingForTechnical::class,
"to" => VacationRequestState::Rejected, "to" => Rejected::class,
])->for($vacationRequestRejected) ])->for($vacationRequestRejected)
->for($technicalApprover) ->for($technicalApprover)
->create(); ->create();
$vacationRequestRejected->changeStateTo(VacationRequestState::Rejected); $vacationRequestRejected->state = new Rejected($vacationRequestRejected);
$vacationRequestRejected->save();
} }
protected function generateAvatarsForUsers(Collection $users): void protected function generateAvatarsForUsers(Collection $users): void

View File

@@ -64,6 +64,16 @@ services:
- toby-dev - toby-dev
restart: unless-stopped restart: unless-stopped
redis:
image: redis:6
container_name: toby-redis
ports:
- ${FORWARD_REDIS_PORT:-6379}:6379
volumes:
- toby-redis-data:/var/lib/redis
networks:
- toby-dev
node: node:
image: node:17.2.0-alpine3.14 image: node:17.2.0-alpine3.14
container_name: toby-node container_name: toby-node
@@ -99,3 +109,5 @@ networks:
volumes: volumes:
toby-pgsql-data: toby-pgsql-data:
name: toby-pgsql-data name: toby-pgsql-data
toby-redis-data:
name: toby-redis-data

View File

@@ -9,7 +9,8 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \
&& docker-php-ext-enable xdebug \ && docker-php-ext-enable xdebug \
;fi ;fi
RUN apk --no-cache add \ RUN pecl install redis \
&& apk --no-cache add \
postgresql-dev \ postgresql-dev \
zip \ zip \
libzip-dev \ libzip-dev \
@@ -19,4 +20,6 @@ RUN apk --no-cache add \
zip \ zip \
gd \ gd \
&& docker-php-ext-configure \ && docker-php-ext-configure \
zip zip \
&& docker-php-ext-enable \
redis