Skip to content

Commit

Permalink
Merge branch 'main' into blumilksoftware#303-add-dusk
Browse files Browse the repository at this point in the history
  • Loading branch information
Madoq authored May 22, 2023
2 parents 7441104 + a5702da commit c1c4dbe
Show file tree
Hide file tree
Showing 60 changed files with 2,356 additions and 2,367 deletions.
39 changes: 19 additions & 20 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ APP_NAME="Toby HR application"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=https://toby.blumilk.localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug
Expand All @@ -15,26 +15,9 @@ DB_USERNAME=toby
DB_PASSWORD=password
DB_ROOT_PASSWORD=example

EXTERNAL_WEBSERVER_PORT=80
EXTERNAL_NODE_PORT=5857

DOCKER_DEV_DB_EXTERNAL_PORT=5432
DOCKER_DEV_DB_DATABASE=${DB_DATABASE}
DOCKER_DEV_DB_USERNAME=${DB_USERNAME}
DOCKER_DEV_DB_PASSWORD=${DB_PASSWORD}
DOCKER_DEV_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}

DOCKER_TEST_DB_EXTERNAL_PORT=5433
DOCKER_TEST_DB_DATABASE=${DB_DATABASE}
DOCKER_TEST_DB_USERNAME=${DB_USERNAME}
DOCKER_TEST_DB_PASSWORD=${DB_PASSWORD}
DOCKER_TEST_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}

REDIS_PORT=6379
REDIS_HOST=toby-redis

XDG_CONFIG_HOME=/tmp

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=redis
Expand All @@ -54,8 +37,6 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME="${APP_NAME}"

DOCKER_INSTALL_XDEBUG=false

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALENDAR_ENABLED=true
Expand All @@ -68,3 +49,21 @@ SLACK_ENABLED=true
SLACK_CLIENT_TOKEN=
SLACK_SIGNING_SECRET=
SLACK_DEFAULT_CHANNEL="#general"

EXTERNAL_WEBSERVER_PORT=8181
EXTERNAL_NODE_PORT=5857

DOCKER_INSTALL_XDEBUG=false
XDG_CONFIG_HOME=/tmp

DOCKER_DEV_DB_EXTERNAL_PORT=5432
DOCKER_DEV_DB_DATABASE=${DB_DATABASE}
DOCKER_DEV_DB_USERNAME=${DB_USERNAME}
DOCKER_DEV_DB_PASSWORD=${DB_PASSWORD}
DOCKER_DEV_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}

DOCKER_TEST_DB_EXTERNAL_PORT=5433
DOCKER_TEST_DB_DATABASE=${DB_DATABASE}
DOCKER_TEST_DB_USERNAME=${DB_USERNAME}
DOCKER_TEST_DB_PASSWORD=${DB_PASSWORD}
DOCKER_TEST_DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
34 changes: 33 additions & 1 deletion .github/workflows/deploy-to-beta-manually.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,38 @@ jobs:
- name: set branch name
run: echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV

- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ env.BRANCH_NAME }}

- name: sync with main branch
run: |
git merge --no-commit --no-ff origin/main
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: build and push image
uses: docker/build-push-action@v4
with:
context: .
file: ./environment/prod/app/Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/toby:beta
cache-from: type=gha, ref=ghcr.io/${{ github.repository_owner }}/toby-beta-build-cache
cache-to: type=gha, ref=ghcr.io/${{ github.repository_owner }}/toby-beta-build-cache, mode=max

- name: run deployment script over ssh
uses: appleboy/[email protected].5
uses: appleboy/[email protected].8
with:
timeout: 10s
command_timeout: 10m
Expand All @@ -32,4 +62,6 @@ jobs:
git fetch
git checkout --force "${{ env.BRANCH_NAME }}"
git pull
git merge --no-commit --no-ff origin/main
make beta-deploy
docker images --filter dangling=true | grep "ghcr.io/blumilksoftware/toby" | awk '{print $3}'| xargs --no-run-if-empty docker rmi
101 changes: 0 additions & 101 deletions .github/workflows/deploy-to-beta.yml

This file was deleted.

28 changes: 27 additions & 1 deletion .github/workflows/deploy-to-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,32 @@ jobs:
runs-on: ubuntu-22.04
name: Deploy to production
steps:
- uses: appleboy/[email protected]
- name: checkout
uses: actions/checkout@v3

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: build and push image
uses: docker/build-push-action@v4
with:
context: .
file: ./environment/prod/app/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/toby:latest
ghcr.io/${{ github.repository_owner }}/toby:${{ github.ref_name }}
cache-from: type=gha, ref=ghcr.io/${{ github.repository_owner }}/toby-prod-build-cache
cache-to: type=gha, ref=ghcr.io/${{ github.repository_owner }}/toby-prod-build-cache, mode=max

- uses: appleboy/[email protected]
env:
BRANCH_NAME: "main"
with:
Expand All @@ -32,3 +57,4 @@ jobs:
git checkout --force "${{ env.BRANCH_NAME }}"
git pull
make prod-deploy
docker images --filter dangling=true | grep "ghcr.io/blumilksoftware/toby" | awk '{print $3}'| xargs --no-run-if-empty docker rmi
2 changes: 1 addition & 1 deletion .github/workflows/test-and-lint-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, intl
coverage: none

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ google-credentials.json
.idea/
.composer
.deployment
/.phpunit.cache
39 changes: 9 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,32 @@ PROD_DOCKER_EXEC = docker compose --file ${DOCKER_COMPOSE_PROD_FILENAME} exec --
export COMPOSE_DOCKER_CLI_BUILD = 1
export DOCKER_BUILDKIT = 1

.PHONY: beta-deploy
beta-deploy: create-deployment-file
docker compose --file ${DOCKER_COMPOSE_BETA_FILENAME} build --pull && \
docker compose --file ${DOCKER_COMPOSE_BETA_FILENAME} up --detach && \
docker compose --file ${DOCKER_COMPOSE_BETA_FILENAME} up --force-recreate --detach && \
echo "App post deploy actions" && \
${BETA_DOCKER_EXEC} toby-beta-php bash post-deploy-actions.sh && \
echo "Worker post deploy actions" && \
${BETA_DOCKER_EXEC} toby-beta-worker bash post-deploy-actions.sh && \
echo "Scheduler post deploy actions" && \
${BETA_DOCKER_EXEC} toby-beta-scheduler bash post-deploy-actions.sh
${BETA_DOCKER_EXEC} toby-beta-app bash post-deploy-actions.sh

.PHONY: beta-reload-config
beta-reload-config:
echo "App config reload" && \
${BETA_DOCKER_EXEC} toby-beta-php bash reload-config.sh && \
echo "Worker config reload" && \
${BETA_DOCKER_EXEC} toby-beta-worker bash reload-config.sh && \
echo "Scheduler config reload" && \
${BETA_DOCKER_EXEC} toby-beta-scheduler bash reload-config.sh
${BETA_DOCKER_EXEC} toby-beta-app bash reload-config.sh

.PHONY: prod-deploy
prod-deploy: create-deployment-file
docker compose --file ${DOCKER_COMPOSE_PROD_FILENAME} build --pull && \
docker compose --file ${DOCKER_COMPOSE_PROD_FILENAME} up --detach && \
docker compose --file ${DOCKER_COMPOSE_PROD_FILENAME} up --force-recreate --detach && \
echo "App post deploy actions" && \
${PROD_DOCKER_EXEC} toby-prod-php bash post-deploy-actions.sh && \
echo "Worker post deploy actions" && \
${PROD_DOCKER_EXEC} toby-prod-worker bash post-deploy-actions.sh && \
echo "Scheduler post deploy actions" && \
${PROD_DOCKER_EXEC} toby-prod-scheduler bash post-deploy-actions.sh
${PROD_DOCKER_EXEC} toby-prod-app bash post-deploy-actions.sh

.PHONY: prod-reload-config
prod-reload-config:
echo "App config reload" && \
${PROD_DOCKER_EXEC} toby-prod-php bash reload-config.sh && \
echo "Worker config reload" && \
${PROD_DOCKER_EXEC} toby-prod-worker bash reload-config.sh && \
echo "Scheduler config reload" && \
${PROD_DOCKER_EXEC} toby-prod-scheduler bash reload-config.sh
${PROD_DOCKER_EXEC} toby-prod-app bash reload-config.sh


DEPLOYMENT_PROJECT_VERSION = $(shell ./environment/scripts/version.sh --long)
DEPLOYMENT_DATETIME = $(shell date --rfc-3339=seconds)
DEPLOYMENT_DATETIME = $(shell TZ=Europe/Warsaw date --rfc-3339=seconds)

.PHONY: create-deployment-file
create-deployment-file:
@echo "\
DEPLOY_DATE='${DEPLOYMENT_DATETIME}'\n\
DEPLOY_VERSION='${DEPLOYMENT_PROJECT_VERSION}'\
" > .deployment

.PHONY: beta-deploy beta-reload-config prod-deploy prod-reload-config create-deployment-file
2 changes: 0 additions & 2 deletions app/Architecture/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class AuthServiceProvider extends ServiceProvider

public function boot(): void
{
$this->registerPolicies();

Gate::before(function (User $user) {
if ($user->role === Role::Administrator) {
return true;
Expand Down
5 changes: 4 additions & 1 deletion app/Architecture/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function boot(): void

protected function configureRateLimiting(): void
{
RateLimiter::for("api", fn(Request $request): Limit => Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()));
RateLimiter::for(
"api",
fn(Request $request): Limit => Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()),
);
}
}
Loading

0 comments on commit c1c4dbe

Please sign in to comment.