{"id":21685130,"url":"https://github.com/corpusops/cookiecutter-symfony","last_synced_at":"2025-07-18T05:32:42.331Z","repository":{"id":37470006,"uuid":"175257191","full_name":"corpusops/cookiecutter-symfony","owner":"corpusops","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-30T17:27:08.000Z","size":426,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"v2","last_synced_at":"2024-03-15T00:03:16.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/corpusops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-12T16:47:09.000Z","updated_at":"2022-11-03T15:11:03.000Z","dependencies_parsed_at":"2023-01-25T22:00:36.403Z","dependency_job_id":null,"html_url":"https://github.com/corpusops/cookiecutter-symfony","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpusops%2Fcookiecutter-symfony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpusops%2Fcookiecutter-symfony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpusops%2Fcookiecutter-symfony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpusops%2Fcookiecutter-symfony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corpusops","download_url":"https://codeload.github.com/corpusops/cookiecutter-symfony/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226358652,"owners_count":17612405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T16:18:24.947Z","updated_at":"2024-11-25T16:18:25.801Z","avatar_url":"https://github.com/corpusops.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Init a Symfony project\n\nIdea is to create it with a wonderful python tool called\n[cookiecutter](https://github.com/audreyr/cookiecutter)\n\n## Install prerequisites\n\n```sh\nif ! ( virtualenv 2\u003e\u00261 \u003e/dev/null );then echo \"ERROR: install venv, on debian/ubuntu: apt install -y virtualenv,fi\";fi\nvirtualenv --python=python3 ~/tools/cookiecutter\n~/tools/cookiecutter/bin/pip install cookiecutter\n```\n\n### For MacOS users\n\nInstall gnu-sed with `brew install gsed` and use it as default with `export PATH=\"/usr/local/opt/gnu-sed/libexec/gnubin:$PATH\"` for the focllowing commands.\n\n## Create a new Symfony project\n- create on gitlab your project (empty)\n- then locally generate the base files (replace with your values)\n\n    ```sh\n    # If you already played with cookiecutter you have this directory with the\n    # old project templates. You may need to refresh it.\n    # ignore this step on first exec (you do not have it yet)\n    cd ~/.cookiecutters/cookiecutter-symfony \\\n        \u0026\u0026 git fetch origin \u0026\u0026 git reset --hard origin/master \\\n        \u0026\u0026 cd -\n    # activate cookiecutter env\n    . ~/tools/cookiecutter/bin/activate\n    # And launch the new 'foobar' project generation!\n    # check most variables in cookiecutter.json file\n    cookiecutter --no-input -f -o ~/out_dir \\\n        https://github.com/corpusops/cookiecutter-symfony.git \\\n        name=foobar \\\n        tld_domain=zorg.com \\\n        git_server=gitlab.makina-corpus.net \\\n        docker_registry= registry.makina-corpus.net \\\n        git_ns=zorg \\\n        local_http_port=8009 \\\n        maintenance_no_503=\"y\" \\\n        dev_port=40001 staging_port=40003 qa_host=\"\" prod_port=40010\n    cd ~/out_dir\n    # review before commit\n    # for relative checkout to work, we need remote objects locally\n    git commit local -m \"Add deploy\"\n    ```\n\n- Read [cookiecutter.json](./cookiecutter.json) for all options\n-  notable options behaviors:\n    - ``use_submodule_for_deploy_code=``: copy deploy submodule inside\n      project for a standalone deployment (no common deploy)\n    - ``local_http_port=NNNN``: local port use by devs to access the project after /etc/hosts edition to map 127.0.0.1 to the ``local_domain`` variable (something like http://project_name.local:local_http_port)\n    - ``php_ver=X.Y``: php version to use\n    - ``Symfony_ver=X.Y``: Symfony version to use\n    - ``remove_cron=y``: will remove cron image and related configuration\n    - ``enable_cron=``: will soft disable (comment crontab) without removing cron.\n    - ``(qa|staging)_host=``: will disable generation for this env\n    - ``tests_(staging|tests)=``: will disable those specific tests in CI\n    - ``registry_is_gitlab_registry=y``: act that registry is gitlab based\n      and use token to register image against and\n      autofill ``register_user`` and ``registry_password``.\n    - ``db_mode=\u003cmode\u003e``: one of ``postgres|postgis|mysql``\n    - ``haproxy=y``: generate haproxy related jobs\n\n- Push the generated files (here on `~/out_dir`) to your new project\n\n### Check the extra needed contents\n\nWe provide a basic `app/composer.json` file. N**No doubt** that you may have to\ncomplement it.\n\nIf you need access to one or more private git repositories for composer, you may\nalso need to add some private ssh keys in `keys/` directory and build a\n`./sys/sbin/pre-composer.sh` script (it should look almost like the other\nsys/sbin/composer scripts, but at the end you can add some ssh-keyscan and ssh\nspecifc configurations like this:)\n\n```sh\n(\n    # \u0026\u0026 $GOSU_CMD ssh-keyscan 37.58.212.66 \u003e\u003e /home/$APP_USER/.ssh/known_hosts \\\n    $GOSU_CMD ssh-keyscan foo.example.com \u003e\u003e /home/$APP_USER/.ssh/known_hosts \\\n    \u0026\u0026 chown $APP_USER:$APP_USER /home/$APP_USER/.ssh/known_hosts \\\n    \u0026\u0026 $GOSU_CMD printf 'Host foo.example.com\\n Preferredauthentications publickey\\n  IdentityFile ...\\n' \u003e /home/$APP_USER/.ssh/config \\\n    \u0026\u0026 chown $APP_USER:$APP_USER /home/$APP_USER/.ssh/config\n)\n```\n\nCheck also the symfony migrate commands or anything needed in the created database.\n\n## Init dev and and test locally\n\n\n```sh\n./control.sh init  # init conf files\n./control.sh build symfony\n./control.sh build  # will be faster as many images are based on symfony\n```\n\nNote that you can also read the generated README.md of the generated project for\ndetails on how to deploy the project locally (like docker dependencies, debugging problems, etc).\n\nIf you launch a `up` action on dev local environement the application is not yet installed. Shared directories with your local installation, containing things like the *vendors*, are empty, and the database may also be empty. A first test may needs commands like these ones :\n\n```sh\n./control.sh up\n./control.sh userexec bin/composerinstall\n./control.sh console doctrine:migrations:migrate --allow-no-migration\n```\n\n## Fill ansible inventory\n\n### Generate ssh deploy key\n```ssh\ncd local\nssh-keygen -t rsa -b 2048 -N '' -C deploy -f deploy\n```\n\n### Generate vaults password file\n```sh\nexport CORPUSOPS_VAULT_PASSWORD=SuperVerySecretPassword\n.ansible/scripts/setup_vaults.sh\n```\n\n- Also add that variable ``CORPUSOPS_VAULT_PASSWORD`` in the gitlab CI/CD variables\n- You would certainly also add ``REGISTRY_USER`` \u0026 ``REGISTRY_PASSWORD``.\n\n### Move vault templates to their encrypted counterparts\n\nFor each file which needs to be encrypted\n\n```sh\n# to find them\nfind .ansible/inventory/group_vars/|grep encrypt\n```\n\n### Generate vaults\nAlso open and read both your project top ``README.md`` and the ``.ansible/README.md``\n\nYou need to\n1. open in a editor:\n\n    ```sh\n    $EDITOR .ansible/inventory/group_vars/dev/default.movemetoencryptedvault.yml\n    ```\n2. In another window/shell, use Ansible vault to create/edit that file without the \"encrypted\" in the filename and\ncopy/paste/adapt the content\n\n    ```sh\n    .ansible/scripts/edit_vault.sh .ansible/inventory/group_vars/dev/default.yml\n    ```\n3. Delete the original file\n\n    ```sh\n    rm -f .ansible/inventory/group_vars/dev/default.movemetoencryptedvault.yml\n    ```\n\n- Wash, rince, repeat for each needing-to-be-encrypted vault.\n- ⚠️Please note⚠️: that you will need to put the previously generated ssh deploy key in ``all/default.yml``\n\n## Push to gitlab\n- Push to gitlab and run the dev job until it succeeds\n- Trigger the dev image release job until it succeeds\n\n\n## Deploy manually\n- Deploy manually one time to see everything is in place\u003cbr/\u003e\n  Remember:\n    - Your local copy is synced as the working directory on target env (with exclusions, see playbooks)\n    - The ``cops_symfony_docker_tag`` controls which docker image is deployed.\n\n    ```sh\n    .ansible/scripts/call_ansible.sh .ansible/playbooks/deploy_key_setup.yml\n    .ansible/scripts/call_ansible.sh -vvv .ansible/playbooks/ping.yml -l dev  # or staging\n    .ansible/scripts/call_ansible.sh -vvv .ansible/playbooks/app.yml \\\n         -e \"{cops_symfony_docker_tag: dev}\" -l dev  # or staging\n    ```\n\n## Update project\nYou can regenerate at a later time the project\n```sh\nlocal/regen.sh  # and verify new files and updates\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorpusops%2Fcookiecutter-symfony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorpusops%2Fcookiecutter-symfony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorpusops%2Fcookiecutter-symfony/lists"}