dsd-codered 0.2.1
A plugin for django-simple-deploy, supporting deployments to CodeRed.
Requires Python: >=3.9
Keywords: django, deployment

# 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.