Skip to content

Commit

Permalink
API setup docs
Browse files Browse the repository at this point in the history
  • Loading branch information
valendesigns committed Apr 11, 2018
1 parent 165ea76 commit 4cdb37d
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
92 changes: 90 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,96 @@

[![Build Status](https://travis-ci.org/xwp/go-tide.svg?branch=develop)](https://travis-ci.org/xwp/go-tide) [![Coverage Status](https://coveralls.io/repos/github/xwp/go-tide/badge.svg?branch=develop)](https://coveralls.io/github/xwp/go-tide?branch=develop) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

@todo
## Common Prerequisites

* Install [Composer][composer]
* Create a new Cloud Project using the [Cloud Console][cloud-console]
* Enable Billing on that project
* [Enable Cloud SQL API][cloud-sql-api-enable]
* Install [Google Cloud SDK][gcloud-sdk]

## Project preparation

Copy the `.env.dist` file to `.env`.

```
cp .env.dist .env
```

Update placeholder values in `.env` to reflect your environment. For example,
Tide API specific details; AWS key pairs; SQS queues and S3 buckets.

Configure Google Cloud SDK with your account and the appropriate project ID:

```
$ gcloud init
```

Create an App Engine application within your new project:

```
$ gcloud app create
```

Then configure the App Engine default GCS bucket for later use. The default App
Engine bucket is named YOUR_PROJECT_ID.appspot.com. Change the default Access
Control List (ACL) of that bucket as follows:

```
$ gsutil defacl ch -u AllUsers:R gs://YOUR_PROJECT_ID.appspot.com
```

Go to the [the Credentials section][credentials-section] of your project in the
Console. Click 'Create credentials' and then click 'Service account key.' For
the Service account, select 'App Engine app default service account.' Then
click 'Create' to create and download the JSON service account key to your
local machine. Save it as `service-account.json` in the `service/api` directory
for use with connecting with both Cloud Storage and Cloud SQL.

## API Setup

First generate the API templates:

```
$ make api.tpl
```

Then install the dependencies as follows:

```
$ make api.composer
```

Next start the API Docker images in isolation:

```
make api.up
```

Last run the setup script:

```
make api.setup
```

Run the setup script to initialize WordPress for the first time or if you would
like a convenient way to update the default values when you change certain
environment variables.

The local database is stored in the `data/api/mysql` directory. If you
ever need to start from scratch delete that directory and run `make api.setup`
again. Be sure to stop the API with `make down` and then start it again with
`make api.up`.

Note: Running `make down` will stop all Docker services.

## Props

[@rheinardkorf](https://github.com/rheinardkorf), [@valendesigns](https://github.com/valendesigns)
[@rheinardkorf](https://github.com/rheinardkorf), [@valendesigns](https://github.com/valendesigns)

[composer]: https://getcomposer.org/
[cloud-console]: https://console.cloud.google.com/
[cloud-sql-api-enable]: https://console.cloud.google.com/flows/enableapi?apiid=sqladmin
[gcloud-sdk]: https://cloud.google.com/sdk/
[credentials-section]: https://console.cloud.google.com/apis/credentials/
8 changes: 8 additions & 0 deletions service/api/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Show available make commands.
api.usage:
@echo "\tapi.up:\n\t\t- Run the API Docker images in isolation with docker-compose up."
@echo "\tapi.composer:\n\t\t- Install the Composer dependencies."
@echo "\tapi.setup:\n\t\t- Run the setup script; API containers must be running to exec into."
@echo "\tapi.tpl:\n\t\t- Generate the API templates."

# Run the API Docker images in isolation with docker-compose up.
api.up:
@docker-compose up api-php

# Install the Composer dependencies.
api.composer: api.tpl
@cd service/api && composer install --no-interaction && cd --
@cd service/api/wp-content/plugins/wp-tide-api && composer install --no-interaction && cd --

# Run the setup script; API containers must be running to exec into.
api.setup:
@docker-compose exec api-php /app/setup.sh
Expand Down

0 comments on commit 4cdb37d

Please sign in to comment.