Skip to content

Commit

Permalink
Update readmes. (pulumi#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Jun 15, 2018
1 parent a615383 commit 67ffb94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
13 changes: 8 additions & 5 deletions cloud-js-containers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat

## Running the App

Note: some values in this example will be different from run to run. These values are indicated
with `***`.

1. Create a new stack:

```
Expand All @@ -19,9 +22,9 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat
```
$ pulumi config set aws:region us-west-2
$ pulumi config set cloud-aws:useFargate true
```
```

1. Restore NPM modules via `npm install`.
1. Restore NPM modules via `npm install` or `yarn install`.

1. Preview and deploy the app via `pulumi update`. The preview will take a few minutes, as it builds a Docker container. A total of 19 resources are created.

Expand All @@ -33,9 +36,9 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat

```bash
$ pulumi stack output
Current stack outputs (1)
Current stack outputs (1)
OUTPUT VALUE
hostname http:https://42dc3ff4-ac65d11-86a100b6e1d7f210.elb.us-west-2.amazonaws.com
hostname http:https://***.elb.us-west-2.amazonaws.com

$ curl $(pulumi stack output hostname)
<html>
Expand All @@ -51,7 +54,7 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat

```
$ pulumi logs --follow
Collecting logs for stack container-quickstart-dev since 2018-05-22T14:25:46.000-07:00.
Collecting logs for stack container-quickstart-dev since 2018-05-22T14:25:46.000-07:00.
2018-05-22T15:33:22.057-07:00[ pulumi-nginx] 172.31.13.248 - - [22/May/2018:22:33:22 +0000] "GET / HTTP/1.1" 200 189 "-" "curl/7.54.0" "-"
```

Expand Down
21 changes: 12 additions & 9 deletions cloud-ts-voting-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ To use this example, make sure [Docker](https://docs.docker.com/engine/installat

## Deploying and running the program

### Configure the deployment
### Configure the deployment

Note: some values in this example will be different from run to run. These values are indicated
with `***`.

1. Login via `pulumi login`.

Expand Down Expand Up @@ -45,19 +48,19 @@ To use this example, make sure [Docker](https://docs.docker.com/engine/installat

### Compile the TypeScript program

1. Restore NPM modules via `npm install`.
1. Restore NPM modules via `npm install` or `yarn install`.

1. Compile the program via `tsc` or `npm run build`.
1. Compile the program via `tsc` or `npm run build` or `yarn run build`.

### Preview and deploy

1. Ensure the Docker daemon is running on your machine, then preview and deploy the program with `pulumi update`. The program deploys 32 resources and takes about 10 minutes to complete.
1. Ensure the Docker daemon is running on your machine, then preview and deploy the program with `pulumi update`. The program deploys 24 resources and takes about 10 minutes to complete.

1. View the stack output properties via `pulumi stack output`. The stack output property `frontendUrl` is the URL and port of the deployed app:

```bash
$ pulumi stack output frontendURL
8f351c44-f9d1584-247a3196f19f7797.elb.us-west-2.amazonaws.com
***.elb.us-west-2.amazonaws.com
```

1. In a browser, navigate to the URL for `frontendURL`. You should see the voting app webpage.
Expand All @@ -80,10 +83,10 @@ At the start of the program, the following lines retrieve the value for the Redi

```typescript
let config = new pulumi.Config("voting-app");
let redisPassword = config.require("redisPassword");
let redisPassword = config.require("redisPassword");
```

In the program, the value can be used like any other variable.
In the program, the value can be used like any other variable.

### Resources

Expand All @@ -96,9 +99,9 @@ let frontend = new cloud.Service("voting-app-frontend", ... )

The definition of `redisCache` uses the [`image` property of `cloud.Service`](https://pulumi.io/reference/pkg/nodejs/@pulumi/cloud-aws/index.html) to point to an existing Docker image. In this case, this is the image `redis` at tag `alpine` on Docker Hub. The `redisPassword` variable is passed to the startup command for this image.

The definition of `frontend` is more interesting, as it uses `build` property of `cloud.Service` to point to a folder with a Dockerfile, which in this case is a Python Flask app. Pulumi automatically invokes `docker build` for you and pushes the container to ECR.
The definition of `frontend` is more interesting, as it uses `build` property of `cloud.Service` to point to a folder with a Dockerfile, which in this case is a Python Flask app. Pulumi automatically invokes `docker build` for you and pushes the container to ECR.

So that the `frontend` container can connect to `redisCache`, the environment variables `REDIS`, `REDIS_PORT` are defined. Using the `redisCache.endpoints` property, it's easy to declare the connection between the two containers.
So that the `frontend` container can connect to `redisCache`, the environment variables `REDIS`, `REDIS_PORT` are defined. Using the `redisCache.endpoints` property, it's easy to declare the connection between the two containers.

The Flask app uses these environment variables to connect to the Redis cache container. See the following in [`frontend/app/main.py`](frontend/app/main.py):

Expand Down

0 comments on commit 67ffb94

Please sign in to comment.