Compare commits

..

6 Commits

Author SHA1 Message Date
deploy 562ea93d78 add jwt secret to prod env file
Build and Deploy Docker / build (push) Successful in 5m31s
Build and Deploy Docker / deploy (push) Successful in 47s
2026-07-14 16:40:46 +02:00
deploy 30f50dcfb7 change config from mariadb to mysql
Build and Deploy Docker / build (push) Successful in 5m48s
Build and Deploy Docker / deploy (push) Successful in 46s
2026-07-14 15:42:57 +02:00
deploy d8022ab205 change docker container name to backend
Build and Deploy Docker / build (push) Successful in 8m35s
Build and Deploy Docker / deploy (push) Successful in 39s
2026-07-14 14:53:45 +02:00
deploy 71c14b0625 add env prod 2026-07-14 14:14:42 +02:00
deploy d9bf86598b add cicd
Build and Deploy Docker / build (push) Failing after 14m19s
Build and Deploy Docker / deploy (push) Has been skipped
2026-07-14 08:05:08 +02:00
deploy 4388a7ec93 add client from rest api 2026-07-14 07:56:35 +02:00
9 changed files with 134 additions and 13 deletions
+52
View File
@@ -0,0 +1,52 @@
name: Build and Deploy Docker
on:
push:
branches:
- masterApi
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: git.rhost.ovh
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./services/www/Dockerfile
push: true
tags: git.rhost.ovh/${{ github.repository }}:latest
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.SERVER_HOST }}
port: ${{ secrets.SERVER_PORT }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /home/ryjek/docker/sprawozdania
docker compose pull backend
docker compose up -d backend
docker compose exec --workdir /var/www/html backend APP_RUNTIME_ENV=prod php bin/console secrets:decrypt-to-local --force
docker compose exec --workdir /var/www/html backend php ./bin/console doctrine:migration:migrate --dry-run
docker compose exec --workdir /var/www/html backend php ./bin/console lexik:jwt:generate-keypair --skip-if-exists
docker compose exec --workdir /var/www/html backend php ./bin/console cache:clear
-10
View File
@@ -38,16 +38,6 @@ services:
- internal - internal
volumes: volumes:
- ./storage/redis:/data - ./storage/redis:/data
# wait_for_it:
# build:
# context: .
# dockerfile: services/wait_for_it/Dockerfile
# networks:
# - internal
# depends_on:
# - database
# command: sh -c "/wait -t 30 database:5432 -- echo 123;"
networks: networks:
internal: internal:
internal: true internal: true
+35
View File
@@ -0,0 +1,35 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
###> symfony/framework-bundle ###
APP_ENV=prod
APP_SECRET=$env(APP_SECRET)$
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
#DATABASE_URL="mysql://app:%env(DATABASE_PASSWORD)%@mariadb:3306/app?serverVersion=8.0.32&charset=utf8mb4"
DATABASE_URL="mysql://app:%env(DATABASE_PASSWORD)%@mysql:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
#DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###
REDIS_URL=redis://redis:6379?timeout=5
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=%env(JWT_PASSPHRASE)%
-1
View File
@@ -1,7 +1,6 @@
###> symfony/framework-bundle ### ###> symfony/framework-bundle ###
.env .env
.env.prod
/.env.local /.env.local
/.env.local.php /.env.local.php
/.env.*.local /.env.*.local
@@ -0,0 +1,3 @@
<?php // dev.JWT_PASSPHRASE.0269d8 on Tue, 14 Jul 2026 16:39:52 +0200
return "\x5D\x0FW\xCF\xA8\x28\xCDN\x8Fk\xE2\x17\xA3\x5Cd\xF7\x15\xA7KeJ\x1A\x27\xF4\x10\xEB\x1A\xFF6U\xAFx\x3C\x84\x5B\xE7\x9D\x01f\xF7\x90\xAC\xAAJ\x82\xA9\xBE\xEDBS2\x16\xA4\x95\x24\x1D\x218\xDF\xF33\x93\xB9\x9A\xAF\xB3\xE7\x02\x22\xABC\xE8\xEDM\x98\x5B\xF7\xFD\x0E\xE8s\x8D\x06\x00\x40m\x9B_\x8F\x27\xF5t3\x97\x8E\xF6y\xAA\xE0\xB7\xF4\xD67\x06\xD0Q\x0B\xFF\x90\x1A\xAC\xA1\x2B\xDA\xA2\x8F6\xF5n\x18.\xDA\x18\x1A\x18\xAC3\xE5\xA28\x9C\xE7\x09\xFF\xCC\x99\x88\x16\x83\x06\x2C\x09z\xF2\x9D\x18\xACT2\xBCqZD\xE9\x93\x96\xCF\xCC\xDDwnp\xFE\xE1o\xA9R\x21\x9B\x5E\x0F\x7C\x0B\xA4\xC9\x11\xCF";
+1
View File
@@ -3,4 +3,5 @@
return [ return [
'API_FAKTUROWNIA' => null, 'API_FAKTUROWNIA' => null,
'DATABASE_PASSWORD' => null, 'DATABASE_PASSWORD' => null,
'JWT_PASSPHRASE' => null,
]; ];
@@ -0,0 +1,3 @@
<?php // prod.JWT_PASSPHRASE.0269d8 on Tue, 14 Jul 2026 16:40:05 +0200
return "\xAF\xFA\xD0CAH\x1B\x27\xB0\x12\x3B\x05\x06\xF5\x18\x90q\xBCr\xE7\x2A\x830\x1A\x19\x02\x2F\xCE\x8CR\xC7\x1C\xA5V\xBA\xC0\xC3\xAC-\x83\x5D\xCB\x87~\xD1\x1E\x95\x2AY\xB8\xA1\x02\xAF\xE7\x60.\xBF\x2F\xD1\xCF3\xB1\xE3\x842\x92\x136\x91\xD1\xFC\xAD\xEE\x2FsC\xFC\x0B\x93\x8AQ\x18\x8F\x93\xBC\x00q\xA3\x93jD\xBF\x1DI\xF3\x98\x94~\x3F\x27\xBB\x9B\x84\x0B\xB0\xBDB\x19\xCC7\xDE\xCF\x2A2\x1C\xAC\x04\xB9\x86\x11\x83C\x3B\x18\xE8\xBBdQ\xC0\xA4\x15\xBCM\x28~\xF4\x0BG\x26\x5Dp\x04\xA5B\xCE\x0F\x5D~\xD8H\xC2\xBE\x18mfep\x07\x1CZ\x2C\x8B7\xBAz\x7C\xF3\x8CuY~\xB5y\xFD\x12\xC7\x9F";
@@ -3,4 +3,5 @@
return [ return [
'APP_SECRET' => null, 'APP_SECRET' => null,
'DATABASE_PASSWORD' => null, 'DATABASE_PASSWORD' => null,
'JWT_PASSPHRASE' => null,
]; ];
@@ -3,6 +3,7 @@ namespace App\Controller\Api;
use App\Entity\Clients; use App\Entity\Clients;
use App\Repository\ClientsRepository; use App\Repository\ClientsRepository;
use App\Services\AddReports;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
@@ -40,9 +41,45 @@ class ClientsController extends AbstractController
} }
#[Route('/add', name: 'add_client', methods: ['POST'])] #[Route('/add', name: 'add_client', methods: ['POST'])]
public function add(Request $request, EntityManagerInterface $entityManager): JsonResponse public function add(Request $request, EntityManagerInterface $entityManager, AddReports $addReports): JsonResponse
{ {
return $this->json($request->toArray(), context: ['groups' => ['client:add', 'client:read']]); $need = [
"strName" => $request->getPayload()->get('name'),
"strAddress" => $request->getPayload()->get('address'),
"dateLegitimacy" => $request->getPayload()->get('legitimacy'),
"dateProclamation" => $request->getPayload()->get('proclamation'),
"intNIP" => $request->getPayload()->get('nip'),
"intPhone" => $request->getPayload()->get('phone'),
"strEmail" => $request->getPayload()->get('email'),
];
$newClient = new Clients();
foreach ($need as $key => $value) {
$cleared = $this->clearType($key, $value);
$method = 'set'.ucfirst($key);
$newClient->{$method}($cleared);
}
$entityManager->persist($newClient);
$entityManager->flush();
$entityManager->getCache()->evictEntityRegion(Clients::class);
$addReports->setClient($newClient);
$addReports->init();
return $this->json(['success' => true]);
}
private function clearType(string $key, mixed $value)
{
if (str_contains($key, 'str')) {
return addslashes($value);
}
if (str_contains($key, 'int')) {
return intval($value);
}
if (str_contains($key, 'date')) {
return new \DateTime($value);
}
} }
// #[Route('/{id}', name: 'show', methods: ['GET'])] // #[Route('/{id}', name: 'show', methods: ['GET'])]