Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Add documentation for cloudify #381

Merged
merged 5 commits into from Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
171 changes: 171 additions & 0 deletions CLOUDIFY_HOWTO.md
@@ -0,0 +1,171 @@
# Deploy an existing Django application

This guide will walk you through the steps need to deploy an existing
Django application.

## Before you begin

Before running this guide, you must install the Cloud SDK, Cloud SQK Proxy.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: SQK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


1. Download and install the
[Cloud SDK](https://cloud.google.com/sdk/docs/quickstarts)

2. Download and install the
[Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/connect-admin-proxy#install)

3. Download and install [Docker](https://docs.docker.com/install/overview/)
(any edition)

4. Prepare your environment for Python development. You have the Python 3.5 or
later, pip and virtualenv installed on your system. For instructions, refer
to the [Python Development Environment Setup Guide](https://cloud.google.com/python/setup).

5. If you don't already one, you need to create a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we assume they will accept the ToS by this step?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to create a new account and go to https://console.cloud.google.com/billing. The TOS automatically pops up after I visit this page.

[Google Cloud Platform billing account](https://console.cloud.google.com/billing).
If you are new to Google Cloud Platform, you may be able to take advantage of
a [free trial](https://cloud.google.com/free/).

## Types of deployment

When deploying your Django application, you can choose which Google serving
technology to use:

### App Engine Standard Environment

A serverless deployment environment that requires minimal configuration and
no server maintenance
[[learn more]](https://cloud.google.com/appengine/).

### Google Kubernetes Engine

A managed container environment that allows extensive customization of the
application's execution environment
[[learn more]](https://cloud.google.com/kubernetes-engine/).

## Setup Django Deploy

1. Change directory to your Django application:

```bash
cd <path/to/your/Django/application>
```

#### If you are already using virtual environment for your Django application

2. Activate your existing virtual environment:

```bash
source <virtualenv_name>/bin/activate
```

3. Install Django Deploy

```bash
pip install django-cloud-deploy
```

#### If you do not use virtual environment for your Django application

2. Create a new virtual environment to run Django Deploy:

```bash
virtualenv -p python3 venv
```

3. Activate the new virtual environment:

```bash
source venv/bin/activate
```

4. Install Django Deploy

```bash
pip install django-cloud-deploy
```

5. Install dependencies of your Django application:

```bash
pip install -r <path/to/your/requirements.txt>
```

## Deploy your Django application

1. Start Django Deploy to create and deploy a new Django application.

When using App Engine:

```bash
django-cloud-deploy cloudify --backend=gae
```

When using Google Kubernetes Engine:

```bash
django-cloud-deploy cloudify --backend=gke
```

After running one of the above commands, you should see:
```bash
12 steps to setup your new project
...
```

2. Follow the prompts displayed in the terminal. Make sure that you remember
the following information:
- the database password for the default user
- the username and password for the
[Django admin site](https://docs.djangoproject.com/en/2.2/ref/contrib/admin/)

3. Once you have answered all of the prompts, your new Django project will be
deployed.

At the end of the process, you will see:
```
Your app is running at <url>
```

4. Open `<url>` in your browser to see your application running.


## Redeploying

When you are done testing your code locally, you can redeploy to the cloud.

1. Start Django Deploy to update your application:

```bash
django-cloud-deploy update
```

After running the above commands, you should see:
```bash
3 steps to update your new project
...
```

2. Follow the prompts displayed in the terminal.

3. Once you have answered all of the prompts, your Django project will be
updated.

At the end of the process, you will see:
```
Your app is running at <url>
```

4. Open `<url>` in your browser to see your updated application running.

## Clean up
To avoid incurring charges to your GCP account for the resources used in this
guide:

1. In the GCP Console, go to the
[Projects page](https://console.cloud.google.com/iam-admin/projects).

2. In the project list, select the project you want to delete and click
**Delete**.

3. In the dialog, type the project ID, and then click **Shut down** to delete
the project.
19 changes: 12 additions & 7 deletions README.md
Expand Up @@ -21,27 +21,27 @@ $ django-cloud-deploy new
[<b>1/11</b>] In order to deploy your application, you must allow Django Deploy to access your Google account.
Press [Enter] to open a browser window to allow access
[<b>2/11</b>] Enter a Google Cloud Platform Project ID, or leave blank to use
[django-799931]: my-cool-site
[django-799931]: my-cool-site
[<b>3/11</b>] Enter a Google Cloud Platform project name, or leave blank to use
[Django Project]: My Cool Site
[<b>4/11</b>] In order to deploy your application, you must enable billing for your Google Cloud Project.
You have the following existing billing accounts:
You have the following existing billing accounts:
1. My Billing Account
Please enter your numeric choice or press [Enter] to create a new billing account: 1
[<b>5/11</b>] Enter a password for the default database user "postgres"
Password:
Password (again):
Password:
Password (again):
[<b>6/11</b>] Enter a new directory path to store project source, or leave blank to use
[/usr/local/google/home/bquinlan/my-cool-site]:
[/usr/local/google/home/bquinlan/my-cool-site]:
[<b>7/11</b>] Enter a Django project name, or leave blank to use
[mysite]: mycoolsite
[<b>8/11</b>] Enter a Django app name, or leave blank to use
[home]: mycoolapp
[<b>9/11</b>] Enter a name for the Django superuser, or leave blank to use
[admin]: myname
[<b>10/11</b>] Enter a password for the Django superuser "myname"
Password:
Password (again):
Password:
Password (again):
[<b>11/11</b>] Enter a e-mail address for the Django superuser, or leave blank to use
[test@example.com]: myname@example.com
</pre>
Expand All @@ -52,6 +52,11 @@ For the fastest path to a working Django application running in the cloud,
see the
[Quickstart](https://github.com/GoogleCloudPlatform/django-cloud-deploy/blob/master/QUICKSTART.md).

# Deploy an existing application

For detailed instructions on how to deploy an existing Django project, see the
[HOWTO](https://github.com/GoogleCloudPlatform/django-cloud-deploy/blob/master/CLOUDIFY_HOWTO.md).

# Building a new application

For detailed instructions on how to create a new Django project and then deploy
Expand Down