Skip to content
Snippets Groups Projects
Commit 310b8bf9 authored by i.vasilenko@iq-adv.ru's avatar i.vasilenko@iq-adv.ru
Browse files

init

parent c46b33ac
No related branches found
No related tags found
1 merge request!1init docker
Showing
with 3912 additions and 93 deletions
app/vendor/
app/node_modules/
CONTAINER_NAME=
APP_BASE_DIR=./app
# Nginx
HTTP_PORT=80
# База данных (PostreSQL)
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_ROOT_USERNAME=
DB_PORT=
GROUP_ID=1000
USER_ID=1000
# IDE
XDEBUG_IDE_KEY=myproject
/.idea/
/.vscode/
.env
Makefile 0 → 100644
.DEFAULT_GOAL:=help
COMPOSE_PREFIX_CMD := DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1
COMMAND ?= /bin/sh
# --------------------------
.PHONY: deploy up build-up build down start stop logs images ps command \
command-root shell-root shell restart rm help
deploy: ## Start using Prod Image in Prod Mode
${COMPOSE_PREFIX_CMD} docker compose -f compose.prod.yaml up --build -d
up: ## Start service
@echo "Starting Application \n (note: Web container will wait App container to start before starting)"
${COMPOSE_PREFIX_CMD} docker compose up -d
build-up: ## Start service, rebuild if necessary
${COMPOSE_PREFIX_CMD} docker compose up --build -d
build: ## Build The Image
${COMPOSE_PREFIX_CMD} docker compose build --no-cache
down: ## Down service and do clean up
${COMPOSE_PREFIX_CMD} docker compose down
start: ## Start Container
${COMPOSE_PREFIX_CMD} docker compose start
stop: ## Stop Container
${COMPOSE_PREFIX_CMD} docker compose stop
logs: ## Tail container logs with -n 1000
@${COMPOSE_PREFIX_CMD} docker compose logs --follow --tail=100
images: ## Show Image created by this Makefile (or docker compose in docker)
@${COMPOSE_PREFIX_CMD} docker compose images
ps: ## Show Containers Running
@${COMPOSE_PREFIX_CMD} docker compose ps
command: ## Execute command ( make command COMMAND=<command> )
@${COMPOSE_PREFIX_CMD} docker compose run --rm app ${COMMAND}
command-root: ## Execute command as root ( make command-root COMMAND=<command> )
@${COMPOSE_PREFIX_CMD} docker compose run --rm -u root app ${COMMAND}
shell-root: ## Enter container shell as root
@${COMPOSE_PREFIX_CMD} docker compose exec -u root app /bin/sh
shell: ## Enter container shell
@${COMPOSE_PREFIX_CMD} docker compose exec app /bin/sh
restart: ## Restart container
@${COMPOSE_PREFIX_CMD} docker compose restart
rm: ## Remove current container
@${COMPOSE_PREFIX_CMD} docker compose rm -f
clear:
docker image prune --filter dangling=true
help: ## Show this help.
@echo "\n\nMake Application Docker Images and Containers using Docker-Compose files"
@echo "Make sure you are using \033[0;32mDocker Version >= 20.1\033[0m & \033[0;32mDocker-Compose >= 1.27\033[0m "
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m ENV=<prod|dev> (default: dev)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
\ No newline at end of file
# Symfony Trainee
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gl.iqdev.team/i.vasilenko/symfony-trainee.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gl.iqdev.team/i.vasilenko/symfony-trainee/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
# Docker Compose шаблон для PHP проекта
> Шаблон основан на репозитории https://github.com/sherifabdlnaby/kubephp.
> Отдельное спасибо Паше.
## Конфигурация
| image | version |
|------------|---------|
| PHP | 8.3.6 |
| Xdebug | 3.3.2 |
| Nginx | 1.25 |
| PostgreSQL | 16 |
## Для каких проектов подходит этот шаблон?
Шаблон подходит для проектов, у которых публичные файлы находятся папке `{путь до корня проекта}/public/`.
В этой папке должны находиться такие файлы как:
1. index.php;
2. изображения и другие медиа файлы;
3. подключаемые css, js файлы;
4. другие файлы, к которым пользователь может получить доступ.
Примеры фреймворков, которые легко можно использовать в этом шаблоне:
1. Symfony
2. Laravel
3. Slim
4. Codeigniter
<details>
<summary>Для работы Yii</summary>
Чтобы работать с Yii, необходимо заменить путь `/app/public` на `/app/web`
1. изменить конфигурацию nginx
в файле `docker/web/nginx/conf.d/app.conf` в 16 строчке заменить `root $base/public;` -> `root $base/web;`
2. в compose-файле изменить volume `${APP_BASE_DIR-.}/public:/app/public` -> `${APP_BASE_DIR-.}/web:/app/web`
3. в файле `docker/web/Dockerfile` в 12 строчке заменить `COPY --chown=www-data:www-data --from=app /app/public /app/public` -> `COPY --chown=www-data:www-data --from=app /app/web /app/web`
> Мог где-то что-то упустить. Разворачивать Yii не пробовал.
</details>
> В частных случаях может потребоваться доработка конфигураций.
## Инструкция
## Настройка Xdebug (PHPStorm)
<details>
<summary>Инструкция</summary>
1. Задать значение в `.env` для `XDEBUG_IDE_KEY`. Например: `xdebug_app_key`.
При изменении настроек, необходимо пересобрать контейнер с php.
<hr>
2. Settings -> Build, Execution, Deployment -> Docker:
Нажимаем "+", указываем своё имя и настраиваем подключение в зависимости от Ваших настроек Docker.
Внизу должна появиться надпись `Connection successful`.
<hr>
3. Settings -> PHP -> CLI Interpreter -> 3 точки:
Нажимаем слева "+" -> `From Docker, Vargant ...`, выбираем пункт `Docker Compose`.
Server -> выбираем тот, что создали на прошлом шаге.
Configuration files -> выбираем `compose.yaml` из этого проекта.
Service -> выбираем контейнер с PHP.
OK
Остальное на Ваш вкус, но в графе Lifecycle лучше оставить connect to existing container.
<hr>
4. Settings -> PHP -> CLI Interpreter:
Выбрать только что созданный конфиг.
<hr>
5. Settings -> PHP -> Servers:
Нажимаем "+", вводим названием (его нужно запомнить), указываем хост (127.0.0.1) и порт, который указали в `.env` для nginx.
Включаем галочку `Use path mappings` и раскрываем папку `Projects Files`, на против `app` указываем `/app`.
<hr>
6. Settings -> PHP -> Debug:
В блоке `Xdebug` находим поле `Debug port` и добавляем туда `9001`.
<hr>
7. Run -> Edit configurations:
Нажимаем на "+", переходим в `PHP Remote Debug`, указываем название.
В поле Server указываем тот, что создали в п.5
IDE key (session_id) указываем тот, что указали в `.env` в поле `XDEBUG_IDE_KEY`
После, на верхней панели, где включается debug, выбираем вариант из п.7.
Теперь можно ставить breakpoints, запускать debug и посылать запросы.
</details>
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"ext-ctype": "*",
"ext-iconv": "*",
"php": ">=8.2",
"symfony/console": "7.0.*",
"symfony/dotenv": "7.0.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "7.0.*",
"symfony/runtime": "7.0.*",
"symfony/yaml": "7.0.*"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"symfony/maker-bundle": "^1.59"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*",
"symfony/polyfill-php82": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.0.*"
}
}
}
This diff is collapsed.
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
];
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
# Note that the session will be started ONLY if you read or write from it.
session: true
#esi: true
#fragments: true
when@test:
framework:
test: true
session:
storage_factory_id: session.storage.factory.mock_file
framework:
router:
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
#default_uri: http://localhost
when@prod:
framework:
router:
strict_requirements: null
<?php
if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) {
require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php';
}
controllers:
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
<?php
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment