Skip to content

Commit

Permalink
Move docker-compose files to root, add npm script, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Feb 13, 2021
1 parent b783703 commit 2186422
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 2 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3'

services:
# API Gateway
traefik:
image: traefik:v2.4
container_name: 'traefik'
restart: unless-stopped
command:
- '--log.level=DEBUG'
- '--api.insecure=true'
- '--providers.docker=true'
- '--providers.docker.exposedbydefault=true'
Expand Down Expand Up @@ -142,9 +142,10 @@ services:
container_name: 'image'
restart: unless-stopped
build:
context: ./image
context: ./src/api/image
dockerfile: Dockerfile
environment:
- NODE_ENV=production
- IMAGE_PORT=4444
- SERVICE_NAME=image
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
Expand Down
41 changes: 41 additions & 0 deletions docker-compose-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3'

services:
# API Gateway
traefik:
image: traefik:v2.4
container_name: 'traefik'
restart: unless-stopped
command:
- '--log.level=DEBUG'
- '--api.insecure=true'
- '--providers.docker=true'
- '--providers.docker.exposedbydefault=true'
- '--entrypoints.web.address=:80'
ports:
- '80:80'
- '8080:8080'
volumes:
- /var/run/docker.sock:/var/run/docker.sock

# Micro Services
image-dev:
container_name: 'image'
restart: unless-stopped
build:
context: ./src/api/image
dockerfile: Dockerfile
environment:
- IMAGE_PORT=4444
- SERVICE_NAME=image
depends_on:
traefik:
condition: service_started
ports:
- '4444'
labels:
# Traefik routing
- 'traefik.http.routers.image.rule=Host(`image.docker.localhost`)'
# Enable gzip compression
- 'traefik.http.routers.image.middlewares=test-compress'
- 'traefik.http.middlewares.test-compress.compress=true'
65 changes: 65 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Docker and Telescope

## Introduction

Telescope uses Docker to deploy all the different parts of our app. If you haven't
worked with Docker before, it's worth taking a few minutes to [learn how it works](https://docs.docker.com/get-started/).

You'll see Docker used in a few places

## Setup

See the [environment setup doc](environment-setup.md) for info specific to your platform.

Once installed, Docker uses the following commands:

- [`docker`](https://docs.docker.com/engine/reference/commandline/cli/)
- [`docker-compose`](https://docs.docker.com/compose/reference/)

## Running Telescope via Docker

We have a number of docker-compose files that control all the apps that we ship:

- `docker-compose.yml` - the development version of our "classic" Telescope app (front-end and back-end)
- `docker-compose-production.yml` - the production version of our "classic" Telescope app (front-end and back-end)

We also have files for our new Microservices Back-end:

- `docker-compose-api.yml` - the development version
- `docker-compose-api-production.yml` - the production version

The docker-compose files define a set of separate servers and services that can
be run together with a single command.

```
# run our development version of the entire Telescope app, building any containers as necessary
docker-compose -f docker-compose.yml up --build
# stop the running containers
docker-compose -f docker-compose.yml down
```

If you want to run a specific app or apps, you can name them:

```
# run our development version of the entire Telescope app, building any containers as necessary
docker-compose -f docker-compose.yml up --build login redis telescope
```

### Running the Microservices

For your convenience, you can use the following `npm` scripts:

```
# start the microservices containers and gateway in development
npm run api:start
# stop the containers
npm run api:stop
```

The services will now be available via the defined routes:

| Service | URL |
| ------------------------ | ------------------------------------ |
| Background Image Service | http://image.docker.localhost/image/ |
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"html-elements": "./tools/html-elements.js"
},
"scripts": {
"api:start": "docker-compose -f docker-compose-api.yml up --build -d",
"api:stop": "docker-compose -f docker-compose-api.yml down",
"install:image-service": "cd src/api/image && npm install",
"install:autodeployment": "cd tools/autodeployment && npm install",
"install:next": "cd src/frontend/next && npm install",
Expand Down

0 comments on commit 2186422

Please sign in to comment.