dodevops


Namedodevops JSON
Version 0.1.17 PyPI version JSON
download
home_pagehttps://github.com/Oakwright/dodevops
SummaryDevops tool for deploying and managing resources on DigitalOcean
upload_time2023-10-15 03:03:56
maintainer
docs_urlNone
authorAbby Oakwright
requires_python>=3.8.1,<4.0
license
keywords devops digitalocean django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **DoDevOps**

DoDevOps is a tool for creating and managing Django apps on DigitalOcean's App Platform. 
It accesses DigitalOcean through the API, so it requires a DigitalOcean API token,
and it requires a DigitalOcean Spaces key for storing media uploads.
Additionally, you must authorize DigitalOcean to pull your GitHub repos.

## Prerequisites:

1) Python 3.9 on Linux or Mac
2) DigitalOcean account https://www.digitalocean.com/?refcode=9ef6f738fd8a
3) DigitalOcean API token: https://cloud.digitalocean.com/account/api/tokens
4) DigitalOcean S3 keys: https://cloud.digitalocean.com/account/api/spaces
5) Authorize DigitalOcean to pull your GitHub repos: https://cloud.digitalocean.com/apps/github/install

# Installation

This tool can be installed with pip. 
If installed in a Django project, it will try to detect some settings from the project such as repo and branch,
as well as enable migration of db.json files and media uploads.

```shell
pip install dodevops
```

To run the tool:

```shell
dodevops
```

# Quickstart

## Migrate an existing Django project to DigitalOcean App Platform

1) Create a virtual environment 
   ```mkvirtualenv dodevops```
2) Make sure pip is up to date
   ```pip install --upgrade pip```
3) Install dodevops
   ```pip install dodevops```
4) Change directory to wherever your Django app is
5) Export environment variables
    ```
    export DIGITALOCEAN_API_TOKEN=dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxx
    export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    export MIGRATE_SCRIPT_1="python manage.py shell -c \"import some_module; some_module.some_function()\""
    export MIGRATE_SCRIPT_2=""
    ```
6) Run dodevops
    ```dodevops```

Technically the DoDevOps doesn't need it's own environment and can be installed in existing environments,
but sometimes isolation is nice.

DoDevOps doesn't have to be run from within a Django folder,
but if .env or .git are available it will try and guess some of your settings for your. 
It does require a /media folder in order to upload media folder to s3,
and it does require db.json if migrating a previous database.
Exporting environment variables isn't required, if not supplied DoDevOps will ask the user to enter them at runtime. 

The environment variables MIGRATE_SCRIPT_x can be used to hold lines of user supplied scripts for the migration job. 
These are single shell lines executed as a pre-deploy task on the live DO server.

# Details

## Generating DO API token

In order for this app to work it needs a valid DigitalOcean Personal Access Token. 
The token is not required after this is run, so it is okay to recyle the token when finished. 
The token can either be stored in a .env file or env variable, or it can be pasted into the app at run time. 

### To generating a new token

Go here: https://cloud.digitalocean.com/account/api/tokens

Pick whatever name you want for the token, it doesn't matter. 
Pick whatever token expiration you want depending on your personal paranoia level. 
Write permissions are required. 

Once the token is generated copy it and paste it somewhere safe like a password manager such as 1password. 
The token won't be displayed again, so if you don't get it saved somewhere safe you'll have to regenerate it.

Protect your token well. 
Anyone with access to your token has the ability to create and destroy things and incur you costs, so be careful with it. 
This is opensource so that you can read the code if you want and verify how the token is used. 
Storing the token in the .env file is convenient, but it is not the most secure, so if you feel paranoid don't do that. 

If you want more info about DO tokens, see here: https://docs.digitalocean.com/reference/api/create-personal-access-token/

## Generating DO Spaces Key

A DO Spaces key is required for storing a media upload folder, as app platform doesn't have storage. 

### To generate an app spaces key 

Go here: https://cloud.digitalocean.com/account/api/spaces 

You can use whatever name you want for the key, it doesn't matter. 
It will display two values, a key ID and a longer access key, save both somewhere safe like a password manager. 
It won't display the access key again, so if you don't save it you'll have to regenerate it. 

You can put the values in an .env file, or enter it at runtime.

Protect the token well.

To learn more about DO Spaces keys, go here: https://docs.digitalocean.com/products/spaces/how-to/manage-access/#access-keys

## Filling out .env file

A .env file isn't required, but if you store values in it then it will save effort.
But if you feel storing values in the .env file isn't secure enough for your personal paranoia levels you can instead enter things at runtime.

The format of the env file is:

```
DIGITALOCEAN_TOKEN=dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AWS_ACCESS_KEY_ID=DOxxxxxxxxxxxxxxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# AWS_REGION=ams3
# APP_NAME=example-rest-app
# COMPONENT_NAME=example-rest
# APP_PREFIX=example
# GH_REPO=xusernamex/xrepox
# GH_BRANCH=main
# DJANGO_ROOT_MODULE=example
# DJANGO_USER_MODULE=core
# SECRET_KEY_ENV_KEY=SECRET_KEY
# SECRET_KEY=change_me
# ALLOWED_HOSTS_ENV_KEY=ALLOWED_HOSTS
# DEBUG=1
# DOMAIN=rest.example.com
# PARENT_DOMAIN=example.com
# OIDC="\"-----BEGIN RSA PRIVATE KEY-----\\n_xxx_\\n-----END RSA PRIVATE KEY-----\\n\""
```

## Linux and Mac

This project uses inquirer to get user input. As far as I know it only works on linux and mac. 
When debugging in pycharm, you may need to set the run/debug settings to use the terminal emulation.
You can find a link with more info here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003383619-Pycharm-2019-termios-error-25-Inappropriate-ioctl-for-device-?page=1#community_comment_6589796593042 and here https://github.com/magmax/python-readchar/issues/11

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Oakwright/dodevops",
    "name": "dodevops",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0",
    "maintainer_email": "",
    "keywords": "devops,digitalocean,django",
    "author": "Abby Oakwright",
    "author_email": "abby.oakwright@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7d/e6/3d1e02ee792b796a53b1fc97fb1a51af7693a5c09b3e89f9c2582a2b3a8a/dodevops-0.1.17.tar.gz",
    "platform": null,
    "description": "# **DoDevOps**\n\nDoDevOps is a tool for creating and managing Django apps on DigitalOcean's App Platform. \nIt accesses DigitalOcean through the API, so it requires a DigitalOcean API token,\nand it requires a DigitalOcean Spaces key for storing media uploads.\nAdditionally, you must authorize DigitalOcean to pull your GitHub repos.\n\n## Prerequisites:\n\n1) Python 3.9 on Linux or Mac\n2) DigitalOcean account https://www.digitalocean.com/?refcode=9ef6f738fd8a\n3) DigitalOcean API token: https://cloud.digitalocean.com/account/api/tokens\n4) DigitalOcean S3 keys: https://cloud.digitalocean.com/account/api/spaces\n5) Authorize DigitalOcean to pull your GitHub repos: https://cloud.digitalocean.com/apps/github/install\n\n# Installation\n\nThis tool can be installed with pip. \nIf installed in a Django project, it will try to detect some settings from the project such as repo and branch,\nas well as enable migration of db.json files and media uploads.\n\n```shell\npip install dodevops\n```\n\nTo run the tool:\n\n```shell\ndodevops\n```\n\n# Quickstart\n\n## Migrate an existing Django project to DigitalOcean App Platform\n\n1) Create a virtual environment \n   ```mkvirtualenv dodevops```\n2) Make sure pip is up to date\n   ```pip install --upgrade pip```\n3) Install dodevops\n   ```pip install dodevops```\n4) Change directory to wherever your Django app is\n5) Export environment variables\n    ```\n    export DIGITALOCEAN_API_TOKEN=dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n    export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxx\n    export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n    export MIGRATE_SCRIPT_1=\"python manage.py shell -c \\\"import some_module; some_module.some_function()\\\"\"\n    export MIGRATE_SCRIPT_2=\"\"\n    ```\n6) Run dodevops\n    ```dodevops```\n\nTechnically the DoDevOps doesn't need it's own environment and can be installed in existing environments,\nbut sometimes isolation is nice.\n\nDoDevOps doesn't have to be run from within a Django folder,\nbut if .env or .git are available it will try and guess some of your settings for your. \nIt does require a /media folder in order to upload media folder to s3,\nand it does require db.json if migrating a previous database.\nExporting environment variables isn't required, if not supplied DoDevOps will ask the user to enter them at runtime. \n\nThe environment variables MIGRATE_SCRIPT_x can be used to hold lines of user supplied scripts for the migration job. \nThese are single shell lines executed as a pre-deploy task on the live DO server.\n\n# Details\n\n## Generating DO API token\n\nIn order for this app to work it needs a valid DigitalOcean Personal Access Token. \nThe token is not required after this is run, so it is okay to recyle the token when finished. \nThe token can either be stored in a .env file or env variable, or it can be pasted into the app at run time. \n\n### To generating a new token\n\nGo here: https://cloud.digitalocean.com/account/api/tokens\n\nPick whatever name you want for the token, it doesn't matter. \nPick whatever token expiration you want depending on your personal paranoia level. \nWrite permissions are required. \n\nOnce the token is generated copy it and paste it somewhere safe like a password manager such as 1password. \nThe token won't be displayed again, so if you don't get it saved somewhere safe you'll have to regenerate it.\n\nProtect your token well. \nAnyone with access to your token has the ability to create and destroy things and incur you costs, so be careful with it. \nThis is opensource so that you can read the code if you want and verify how the token is used. \nStoring the token in the .env file is convenient, but it is not the most secure, so if you feel paranoid don't do that. \n\nIf you want more info about DO tokens, see here: https://docs.digitalocean.com/reference/api/create-personal-access-token/\n\n## Generating DO Spaces Key\n\nA DO Spaces key is required for storing a media upload folder, as app platform doesn't have storage. \n\n### To generate an app spaces key \n\nGo here: https://cloud.digitalocean.com/account/api/spaces \n\nYou can use whatever name you want for the key, it doesn't matter. \nIt will display two values, a key ID and a longer access key, save both somewhere safe like a password manager. \nIt won't display the access key again, so if you don't save it you'll have to regenerate it. \n\nYou can put the values in an .env file, or enter it at runtime.\n\nProtect the token well.\n\nTo learn more about DO Spaces keys, go here: https://docs.digitalocean.com/products/spaces/how-to/manage-access/#access-keys\n\n## Filling out .env file\n\nA .env file isn't required, but if you store values in it then it will save effort.\nBut if you feel storing values in the .env file isn't secure enough for your personal paranoia levels you can instead enter things at runtime.\n\nThe format of the env file is:\n\n```\nDIGITALOCEAN_TOKEN=dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nAWS_ACCESS_KEY_ID=DOxxxxxxxxxxxxxxxxxxx\nAWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n# AWS_REGION=ams3\n# APP_NAME=example-rest-app\n# COMPONENT_NAME=example-rest\n# APP_PREFIX=example\n# GH_REPO=xusernamex/xrepox\n# GH_BRANCH=main\n# DJANGO_ROOT_MODULE=example\n# DJANGO_USER_MODULE=core\n# SECRET_KEY_ENV_KEY=SECRET_KEY\n# SECRET_KEY=change_me\n# ALLOWED_HOSTS_ENV_KEY=ALLOWED_HOSTS\n# DEBUG=1\n# DOMAIN=rest.example.com\n# PARENT_DOMAIN=example.com\n# OIDC=\"\\\"-----BEGIN RSA PRIVATE KEY-----\\\\n_xxx_\\\\n-----END RSA PRIVATE KEY-----\\\\n\\\"\"\n```\n\n## Linux and Mac\n\nThis project uses inquirer to get user input. As far as I know it only works on linux and mac. \nWhen debugging in pycharm, you may need to set the run/debug settings to use the terminal emulation.\nYou can find a link with more info here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003383619-Pycharm-2019-termios-error-25-Inappropriate-ioctl-for-device-?page=1#community_comment_6589796593042 and here https://github.com/magmax/python-readchar/issues/11\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Devops tool for deploying and managing resources on DigitalOcean",
    "version": "0.1.17",
    "project_urls": {
        "Homepage": "https://github.com/Oakwright/dodevops",
        "Repository": "https://github.com/Oakwright/dodevops"
    },
    "split_keywords": [
        "devops",
        "digitalocean",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac8ce723a50b07973b33783fd9bca63ca791ba96f74db5b00c460f959bdf70f6",
                "md5": "293f5ae4609f9128903a63467bda6b43",
                "sha256": "28b58d875eeebd933b75c3481f2c6f3b012ff86da6bdfd4855f95e2094f05634"
            },
            "downloads": -1,
            "filename": "dodevops-0.1.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "293f5ae4609f9128903a63467bda6b43",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0",
            "size": 19723,
            "upload_time": "2023-10-15T03:03:53",
            "upload_time_iso_8601": "2023-10-15T03:03:53.977996Z",
            "url": "https://files.pythonhosted.org/packages/ac/8c/e723a50b07973b33783fd9bca63ca791ba96f74db5b00c460f959bdf70f6/dodevops-0.1.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7de63d1e02ee792b796a53b1fc97fb1a51af7693a5c09b3e89f9c2582a2b3a8a",
                "md5": "8f4136fde4145e93cc895be6f7698e91",
                "sha256": "c95099b59070f4d410dce75366519eb80aa884d49ee6b59db2daddbdea8d62a5"
            },
            "downloads": -1,
            "filename": "dodevops-0.1.17.tar.gz",
            "has_sig": false,
            "md5_digest": "8f4136fde4145e93cc895be6f7698e91",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0",
            "size": 22170,
            "upload_time": "2023-10-15T03:03:56",
            "upload_time_iso_8601": "2023-10-15T03:03:56.303559Z",
            "url": "https://files.pythonhosted.org/packages/7d/e6/3d1e02ee792b796a53b1fc97fb1a51af7693a5c09b3e89f9c2582a2b3a8a/dodevops-0.1.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-15 03:03:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Oakwright",
    "github_project": "dodevops",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dodevops"
}
        
Elapsed time: 0.12888s