Skip to content

Commit

Permalink
Add docs, and move secrets to config/*
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Mar 30, 2022
1 parent b03059d commit 6abc2e7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ The steps to launch Telescope in staging or production mode are almost identical

## Directory Structure

The project needs to be set up using a specific directory structure to make sure that Telescope has access to the SSL certificates, redis data and elasticsearch data, and to prevent the certificates and the stored data from being deleted during a redeployment.
The project needs to be set up using a specific directory structure to make sure that Telescope has access to the SSL certificates and shared data volumes (redis, elasticsearch, postgres), and to prevent the certificates and the stored data from being deleted during a redeployment.

Also, we use an extra `env` file to store secrets in `config/env.production.secrets` (production) and `config/env.staging.secrets` (staging). These do **not** go in git, and must be maintained manually.

```sh
├── parent-directory
│ ├── autodeployment
│ ├── certbot
│ ├── config
│ │ └── env.production.secrets
│ ├── elastic-data
| ├── postgres-data
│ ├── redis-data
│ └── telescope
```
Expand Down Expand Up @@ -57,6 +62,7 @@ sudo chown -R <user_name>: certbot
### 3.- Autodeployment server

Telescope uses [GitHub webhooks](https://docs.github.com/en/developers/webhooks-and-events/about-webhooks) to automate deployments whenever a pull requests is merged or a new version is released.

When a GitHub event is triggered, it sends a POST request payload to the webhook's configured URL. Telescope's autodeployment server receives that POST request and updates Telescope with the latest merged changes or with a new release.

After [creating a GitHub webhook](https://docs.github.com/en/developers/webhooks-and-events/creating-webhooks), copy the `autodeployment` directory in `tools` in the repository to the chosen directory where the project lives, as indicated above.
Expand Down
35 changes: 17 additions & 18 deletions tools/autodeployment/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Auto Deployment

Telescope uses a separate HTTP server to listen for
[GitHub Webhook](https://developer.github.com/webhooks/)Events. The server's
[GitHub Webhook](https://developer.github.com/webhooks/) Events. The server's
configuration is stored in an `.env` file, which must be created based on
`env.example`.

On our staging (https://dev.telescope.cdot.systems) and production
(https://telescope.cdot.systems) machines we use these webhooks to trigger a new
build and deploy. For staging, this happens on every push to the `master`
branch. On production, we listen for GitHub releases (e.g., when a new release
is created on GitHub).
On our staging (<https://dev.telescope.cdot.systems>) and production
(<https://telescope.cdot.systems>) machines listen for a `push` to the webhook, and then trigger a new build and deploy using the `deploy.sh` script.

## Routes

There are also a few other routes you can use to get information about the
auto deployment server:
Expand All @@ -19,27 +18,27 @@ auto deployment server:

On staging you can go to:

- https://dev.telescope.cdot.systems/deploy/status to check the deployment status,
- https://dev.telescope.cdot.systems/deploy/log to check the deployment log of
the current deployment (you can also use https://dev.telescope.cdot.systems/deploy/log/current),
- https://dev.telescope.cdot.systems/deploy/log/previous to check the deployment log of
- <https://dev.telescope.cdot.systems/deploy/status> to check the deployment status,
- <https://dev.telescope.cdot.systems/deploy/log> to check the deployment log of
the current deployment (you can also use <https://dev.telescope.cdot.systems/deploy/log/current>),
- <https://dev.telescope.cdot.systems/deploy/log/previous> to check the deployment log of
the previous deployment,

and on production you can use

- https://telescope.cdot.systems/deploy/status to check the deployment status,
- https://telescope.cdot.systems/deploy/log to check the deployment log of the
current deployment (you can also use https://telescope.cdot.systems/deploy/log/current),
- https://telescope.cdot.systems/deploy/log/previous to check the deployment log of
- <https://telescope.cdot.systems/deploy/status> to check the deployment status,
- <https://telescope.cdot.systems/deploy/log> to check the deployment log of the
current deployment (you can also use <https://telescope.cdot.systems/deploy/log/current>),
- <https://telescope.cdot.systems/deploy/log/previous> to check the deployment log of
the previous deployment.

## Real-time build log

In the dashboard, you can check the log in real-time through the following links:

- https://dev.api.telescope.cdot.systems/v1/status/build for `staging`
- https://api.telescope.cdot.systems/v1/status/build for `production`
- <https://dev.api.telescope.cdot.systems/v1/status/build> for `staging`
- <https://api.telescope.cdot.systems/v1/status/build> for `production`

```
$ curl https://dev.telescope.cdot.systems/deploy/log
```sh
curl https://dev.telescope.cdot.systems/deploy/log
```
4 changes: 2 additions & 2 deletions tools/autodeployment/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ if [ $1 = 'production' ]
then
ENV_FILE=config/env.production
# The env.secrets file doesn't live in git
SECRETS_ENV_FILE=../env.production.secrets
SECRETS_ENV_FILE=../config/env.production.secrets
elif [ $1 = 'staging' ]
then
ENV_FILE=config/env.staging
# The env.secrets file doesn't live in git
SECRETS_ENV_FILE=../env.staging.secrets
SECRETS_ENV_FILE=../config/env.staging.secrets
else
echo $1 is not a valid argument. Please use either production or staging.
exit 1
Expand Down

0 comments on commit 6abc2e7

Please sign in to comment.