Metadata-Version: 2.2
Name: dsd-codered
Version: 0.2.1
Summary: A plugin for django-simple-deploy, supporting deployments to CodeRed.
Author-email: Eric Matthes <ehmatthes@gmail.com>
Keywords: django,deployment
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=4.2
Requires-Dist: pluggy>=1.5.0
Requires-Dist: toml>=0.10.2
Requires-Dist: requests>=2.32.2
Requires-Dist: django-simple-deploy>=0.9.0
Requires-Dist: cr
Provides-Extra: dev
Requires-Dist: black>=24.1.0; extra == "dev"
Requires-Dist: build>=1.2.1; extra == "dev"
Requires-Dist: pytest>=8.3.0; extra == "dev"
Requires-Dist: twine>=5.1.1; extra == "dev"

# dsd-codered

A plugin for deploying Django projects to CodeRed, using django-simple-deploy.

Quick Start
---

To deploy your project to CodeRed, you'll need to take some steps through the CodeRed web site. But once you set up an initial project there, django-simple-deploy can make all the necessary changes to your project for a successful deployment.

## Prerequisites

Deployment to CodeRed requires the following:

- You must be using Git to track your project.
- You need to be tracking your dependencies with a `requirements.txt` file, or be using Poetry or Pipenv.
- You'll need a [CodeRed account](https://app.codered.cloud/login/), and an [API token](https://www.codered.cloud/docs/cli/quickstart/).
- You need to create a Django project in the CodeRed admin interface:
  - Choose Django, and set the database to Postgres.

## Configuration-only deployment

First, install `dsd-codered` and add `django_simple_deploy` to `INSTALLED_APPS` in *settings.py*:

```sh
$ pip install dsd-codered
# Add "django_simple_deploy" to INSTALLED_APPS in settings.py.
$ git commit -am "Added django_simple_deploy to INSTALLED_APPS."
```

When you install `dsd-codered`, it will install `django-simple-deploy` as a dependency.

Now run the `deploy` command:

```sh
$ python manage.py deploy
```

This is the `deploy` command from `django-simple-deploy`, which makes all the changes you need to run your project on CodeRed.

At this point, you should review the changes that were made to your project. Running `git status` will show you which files were modified, and which files were created for a successful deployment. If you want to continue with the deployment process, commit these changes. Then set an environment variable with your CodeRed API token, and run the `cr deploy` command:

```sh
$ git add .
$ git commit -m "Configured for deployment to CodeRed."
$ export CR_TOKEN=<api-token>
$ cr deploy <codered-app-name>
```

Here, `<codered-app-name>` is the name you chose when you created a new project in the CodeRed admin interface. The last line of output will show you the URL for your deployed project. You can also find this URL in your CodeRed admin interace.

You can find a record of the deployment process in `dsd_logs/`. It contains most of the output you saw when running `deploy`.

## Automated deployment

You can automate most of this process:

- Create a Django project in the CodeRed admin interface. Choose Django, and set the database to Postgres.
- Next, install `dsd-codered` and add `django_simple_deploy` to `INSTALLED_APPS` in *settings.py*:

```sh
$ pip install dsd-codered
# Add "django_simple_deploy" to INSTALLED_APPS in settings.py.
```

Now, set an environment variable with your CodeRed API token and run `deploy` in the fully automated mode:

```sh
$ export CR_TOKEN=<api-token>
$ python manage.py deploy --automate-all
```

You'll be prompted for the name of the project you created in the CodeRed dashboard. Your project will then be configured, all changes will be committed, and your project will be deployed to CodeRed's servers. When everything's complete, your project should open in a new browser tab.

Deleting a project from CodeRed
---

If you want to delete a project from CodeRed, you can do so in their dashboard. Look at the bottom of the Settings page.
