Name | django-ssh-deployer JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | Deploys Django websites via management commands over SSH via Paramiko. |
upload_time | 2024-07-10 18:09:15 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | BSD-3-Clause |
keywords |
standard
and
poors
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Django SSH Deployer
This package provides a Django management command to deploy your site to various instances (develop, stage, production) over SSH via Paramiko.
## Pre-Requisites
With great power comes great responsibility! Target servers (`DEPLOYER_INSTANCES['instance']['servers']`) must each have `git` and Python 3.3+ installed, and support Linux-style OS commands. Target servers must have a user (`DEPLOYER_INSTANCES['instance']['server_user']`) with keys set up from the control machine where you run the Django command from. This typically means installing the control machine account's public key into the target server's user account's `AUTHORIZED_KEYS`.
## Installation and Required Django Settings
Install via `pip` into your development environment:
```bash
pip install django-ssh-deployer
```
Then add `django_ssh_deployer` to your `INSTALLED_APPS`. Next, we need to configure your instances in Django's settings; these can live in your development or local settings, as they won't be required by production.
```python
DEPLOYER_INSTANCES = {
"dev": {
"name": "your-project",
"repository": "git@github.com:youruser/your-project.git",
"branch": "dev",
"settings": "config.settings.dev",
"pip_command": "-e .[dev]",
"code_path": "/var/django/sites",
"venv_python_path": "/usr/bin/python3",
"upgrade_pip": True,
"servers": ["devserver.example.com"],
"server_user": "deploy_user",
"save_deploys": 3,
"selinux": False,
"collectstatic": False,
"migrate": False,
},
"prod": {
"name": "your-project",
"repository": "git@github.com:youruser/your-project.git",
"branch": "prod",
"settings": "config.settings.prod",
"requirements": "requirements/prod.txt",
"code_path": "/var/django/sites",
"venv_python_path": "/usr/bin/python3",
"upgrade_pip": True,
"servers": ["prodserver-1.example.com", "prodserver-2.example.com"],
"server_user": "deploy_user",
"save_deploys": 3,
"selinux": True,
"additional_commands": [
"chmod -R a+rX /var/django/sites/your-project-prod",
"curl -kLs -o /dev/null --max-time 5 --resolve 'your-domain.com:443:127.0.0.1' https://your-domain.com/",
],
},
}
```
* `name`: A name for your project.
* `repository`: The repository for your Django project, which will be cloned on each target server.
* `branch`: The branch to check out for the instance.
* `settings`: A full path to the Django settings for the instnace.
* `requirements` or `pip_command`: Either a relative path to a `requirements` file, or a pip path to be `pip install`'d for the instance.
* `code_path`: The root path for your code repository to be checked out to on the target servers.
* `venv_python_path`: The full path to the version of Python for the `venv` to use on the target servers.
* `servers`: A list of servers to deploy the Django project to.
* `server_user`: The user on the target servers which has been set up with keys from the control machine.
* (optional) `upgrade_pip`: If set to `False`, will not upgrade `pip` to the latest version.
* (optional) `collectstatic`: If set to `False`, will not collect static files.
* (optional) `migrate`: If set to `False`, will not run migrations.
* (optional) `save_deploys`: If a positive integer, will only keep the most recent number of deployments. By default, will keep all.
* (optional) `selinux`: If set to True, the deployer will run `chcon` command to set the necessary security context on files for SELinux. It will set all files in the `codepath` to `httpd_sys_content_t`, and any `*.so` files in the `venv` to `httpd_sys_script_exec_t`.
* (optional) `additional_commands`: A list of commands to run after the deployment is complete.
Optionally, you can customize the directory created by the `git clone` in your Django settings:
```
DEPLOYER_CLONE_DIR_FORMAT = "{name}-{instance}"
```
The following keywords will be replaced in the checkout directory format: `instance`, `name`, `branch`, and `server_user`. The default is `"{name}-{instance}"`, which in the example above, would be `your-project-develop` and `your-project-production`.
## Running the Command
```bash
python manage.py deploy --instance=develop
```
* `--instance`: Required. The name of the instance to deploy in `DEPLOYER_INSTANCES`. In the example above, either `develop` or `production`.
* `--quiet`: Less verbose output. Does not display the output of the commands being run to the terminal.
* `--no-confirm`: Publishes without a confirmation step. Be careful!
* `--stamp`: By default, Django SSH Deployer will append a datetime stamp to the `git clone`. This overrides the datetime default.
## What It Does
The `deploy` command will SSH to each server in `servers` as the `server_user`, and perform the following functions in two passes.
First, it will connect to each server and prepare the new deployment:
* clone the repository from git with a stamp
* create a `venv` with a stamp
* run the `collectstatic` command
After the deployment has been prepared on all servers without error, it will proceed to the final deployment steps:
* run the `migrate` command on the first server only
* create or update the symlink to point to the completed deploy on each server
## Known Limitations and Issues
* Windows servers are not supported, however, you can use Windows as your control machine.
* Your repository's host must be in your target server's known hosts list, as git checkouts over SSH require an initial fingerprint.
* This is not meant to be a replacement for a fully featured continous integration product, like Jenkins.
## Release Notes
[Release notes are available on GitHub.](https://github.com/FlipperPA/django-ssh-deployer/releases)
## Contributors
* Timothy Allen (https://github.com/FlipperPA)
Raw data
{
"_id": null,
"home_page": null,
"name": "django-ssh-deployer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "standard and poors",
"author": null,
"author_email": "Tim Allen <flipper@peregrinesalon.com>",
"download_url": "https://files.pythonhosted.org/packages/f5/80/6171c659a92712119e10d0385f050ce1e08a2d323e4d969ca2732f23526b/django_ssh_deployer-1.0.0.tar.gz",
"platform": null,
"description": "# Django SSH Deployer\n\nThis package provides a Django management command to deploy your site to various instances (develop, stage, production) over SSH via Paramiko.\n\n## Pre-Requisites\n\nWith great power comes great responsibility! Target servers (`DEPLOYER_INSTANCES['instance']['servers']`) must each have `git` and Python 3.3+ installed, and support Linux-style OS commands. Target servers must have a user (`DEPLOYER_INSTANCES['instance']['server_user']`) with keys set up from the control machine where you run the Django command from. This typically means installing the control machine account's public key into the target server's user account's `AUTHORIZED_KEYS`.\n\n## Installation and Required Django Settings\n\nInstall via `pip` into your development environment:\n\n```bash\npip install django-ssh-deployer\n```\n\nThen add `django_ssh_deployer` to your `INSTALLED_APPS`. Next, we need to configure your instances in Django's settings; these can live in your development or local settings, as they won't be required by production.\n\n```python\nDEPLOYER_INSTANCES = {\n \"dev\": {\n \"name\": \"your-project\",\n \"repository\": \"git@github.com:youruser/your-project.git\",\n \"branch\": \"dev\",\n \"settings\": \"config.settings.dev\",\n \"pip_command\": \"-e .[dev]\",\n \"code_path\": \"/var/django/sites\",\n \"venv_python_path\": \"/usr/bin/python3\",\n \"upgrade_pip\": True,\n \"servers\": [\"devserver.example.com\"],\n \"server_user\": \"deploy_user\",\n \"save_deploys\": 3,\n \"selinux\": False,\n \"collectstatic\": False,\n \"migrate\": False,\n },\n \"prod\": {\n \"name\": \"your-project\",\n \"repository\": \"git@github.com:youruser/your-project.git\",\n \"branch\": \"prod\",\n \"settings\": \"config.settings.prod\",\n \"requirements\": \"requirements/prod.txt\",\n \"code_path\": \"/var/django/sites\",\n \"venv_python_path\": \"/usr/bin/python3\",\n \"upgrade_pip\": True,\n \"servers\": [\"prodserver-1.example.com\", \"prodserver-2.example.com\"],\n \"server_user\": \"deploy_user\",\n \"save_deploys\": 3,\n \"selinux\": True,\n \"additional_commands\": [\n \"chmod -R a+rX /var/django/sites/your-project-prod\",\n \"curl -kLs -o /dev/null --max-time 5 --resolve 'your-domain.com:443:127.0.0.1' https://your-domain.com/\",\n ],\n },\n}\n```\n\n* `name`: A name for your project.\n* `repository`: The repository for your Django project, which will be cloned on each target server.\n* `branch`: The branch to check out for the instance.\n* `settings`: A full path to the Django settings for the instnace.\n* `requirements` or `pip_command`: Either a relative path to a `requirements` file, or a pip path to be `pip install`'d for the instance.\n* `code_path`: The root path for your code repository to be checked out to on the target servers.\n* `venv_python_path`: The full path to the version of Python for the `venv` to use on the target servers.\n* `servers`: A list of servers to deploy the Django project to.\n* `server_user`: The user on the target servers which has been set up with keys from the control machine.\n* (optional) `upgrade_pip`: If set to `False`, will not upgrade `pip` to the latest version.\n* (optional) `collectstatic`: If set to `False`, will not collect static files.\n* (optional) `migrate`: If set to `False`, will not run migrations.\n* (optional) `save_deploys`: If a positive integer, will only keep the most recent number of deployments. By default, will keep all.\n* (optional) `selinux`: If set to True, the deployer will run `chcon` command to set the necessary security context on files for SELinux. It will set all files in the `codepath` to `httpd_sys_content_t`, and any `*.so` files in the `venv` to `httpd_sys_script_exec_t`.\n* (optional) `additional_commands`: A list of commands to run after the deployment is complete.\n\nOptionally, you can customize the directory created by the `git clone` in your Django settings:\n\n```\nDEPLOYER_CLONE_DIR_FORMAT = \"{name}-{instance}\"\n```\n\nThe following keywords will be replaced in the checkout directory format: `instance`, `name`, `branch`, and `server_user`. The default is `\"{name}-{instance}\"`, which in the example above, would be `your-project-develop` and `your-project-production`.\n\n## Running the Command\n\n```bash\npython manage.py deploy --instance=develop\n```\n\n* `--instance`: Required. The name of the instance to deploy in `DEPLOYER_INSTANCES`. In the example above, either `develop` or `production`.\n* `--quiet`: Less verbose output. Does not display the output of the commands being run to the terminal.\n* `--no-confirm`: Publishes without a confirmation step. Be careful!\n* `--stamp`: By default, Django SSH Deployer will append a datetime stamp to the `git clone`. This overrides the datetime default.\n\n## What It Does\n\nThe `deploy` command will SSH to each server in `servers` as the `server_user`, and perform the following functions in two passes.\n\nFirst, it will connect to each server and prepare the new deployment:\n\n* clone the repository from git with a stamp\n* create a `venv` with a stamp\n* run the `collectstatic` command\n\nAfter the deployment has been prepared on all servers without error, it will proceed to the final deployment steps:\n\n* run the `migrate` command on the first server only\n* create or update the symlink to point to the completed deploy on each server\n\n## Known Limitations and Issues\n\n* Windows servers are not supported, however, you can use Windows as your control machine.\n* Your repository's host must be in your target server's known hosts list, as git checkouts over SSH require an initial fingerprint.\n* This is not meant to be a replacement for a fully featured continous integration product, like Jenkins.\n\n## Release Notes\n\n[Release notes are available on GitHub.](https://github.com/FlipperPA/django-ssh-deployer/releases)\n\n## Contributors\n\n* Timothy Allen (https://github.com/FlipperPA)\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Deploys Django websites via management commands over SSH via Paramiko.",
"version": "1.0.0",
"project_urls": {
"Documentation": "https://github.com/FlipperPA/django-ssh-deployer",
"Homepage": "https://github.com/FlipperPA/django-ssh-deployer",
"Repository": "https://github.com/FlipperPA/django-ssh-deployer"
},
"split_keywords": [
"standard",
"and",
"poors"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "21254f272ee690a9f4c86428e02b052d6445c3aacf1af3c0db4e6f92b91f2213",
"md5": "4c5f87b7608dbf5b1f78ba4de668462c",
"sha256": "ef28b340792edb98c063c6c3f256ff6badd42b4c50594e12329d2898cbd5e5cd"
},
"downloads": -1,
"filename": "django_ssh_deployer-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4c5f87b7608dbf5b1f78ba4de668462c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 8533,
"upload_time": "2024-07-10T18:09:14",
"upload_time_iso_8601": "2024-07-10T18:09:14.320320Z",
"url": "https://files.pythonhosted.org/packages/21/25/4f272ee690a9f4c86428e02b052d6445c3aacf1af3c0db4e6f92b91f2213/django_ssh_deployer-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f5806171c659a92712119e10d0385f050ce1e08a2d323e4d969ca2732f23526b",
"md5": "2504971171cd0d00909a5a931ef53523",
"sha256": "eb0163868ab51eda9434c9979a80a38e0ebd8cc3e6410e95532906278bc1f4e5"
},
"downloads": -1,
"filename": "django_ssh_deployer-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "2504971171cd0d00909a5a931ef53523",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 10429,
"upload_time": "2024-07-10T18:09:15",
"upload_time_iso_8601": "2024-07-10T18:09:15.443485Z",
"url": "https://files.pythonhosted.org/packages/f5/80/6171c659a92712119e10d0385f050ce1e08a2d323e4d969ca2732f23526b/django_ssh_deployer-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-10 18:09:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "FlipperPA",
"github_project": "django-ssh-deployer",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django-ssh-deployer"
}