Preparation

Here's how to create a Docker network and deploy a set of Docker compose files. We use the concept of metastack to deploy multiple stacks and have some labels and naming conventions to group them together:

$ docker network create 
--driver=weaveworks/net-plugin:2.1.3
--subnet=10.32.2.0/24
--attachable
parse_net

$ docker volume create mongo_data

$ docker stack deploy -c mongodb.yml parse_01
$ docker stack deploy -c parse.yml parse_02
$ docker stack deploy -c parse_dashboard.yml parse_03
$ docker stack deploy -c ingress.yml parse_04

While deploying things on production, we do not set up the network and volumes with any Docker compose files. All stacks should refer to external volumes and networks.

Starting with MongoDB, we have already set up a volume for it. The following is the setup of the MongoDB server:

version: '3.3'

services:
mongo:
image: mongo:3.6.1-jessie
volumes:
- mongo_data:/data/db

volumes:
mongo_data:
external: true

networks:
default:
external:
name: parse_net

We move to the next component, the Parse platform. To make the container work with Træfik, we put some labels to the service, saying that it will be on the parse_net network and will expose port 1337 to Træfik's ingress.

We add a rule to allow every HTTP method, also to define the custom entrypoint, and allow Origin=* to enable the Parse dashboard, the next section, to be able to connect to the Parse server:

version: '3.3'

services:

parse_server:
image: parseplatform/parse-server:2.6.5
command: --appId APP1 --masterKey MASTER_KEY --databaseURI mongodb://mongo/prod
deploy:
labels:
- "traefik.docker.network=parse_net"
- "traefik.port=1337"
- "traefik.frontend.rule=Method: GET,POST,PUT,DELETE,OPTIONS,HEAD,CONNECT"
- "traefik.frontend.entryPoints=parse_server"
- "traefik.frontend.headers.customresponseheaders.Access-Control-Allow-Origin=*"

networks:
default:
external:
name: parse_net

Here's the Parse dashboard and its configuration. The current version of the dashboard is 1.1.2. It will be exposed to port 4040 via Træfik's ingress:

version: '3.3'

services:

parse_dashboard:
image: parseplatform/parse-dashboard:1.1.2
environment:
- PARSE_DASHBOARD_ALLOW_INSECURE_HTTP=true
deploy:
labels:
- "traefik.docker.network=parse_net"
- "traefik.port=4040"
- "traefik.frontend.rule=Method: GET,POST,PUT,DELETE,OPTIONS,HEAD,CONNECT"
- "traefik.frontend.entryPoints=parse_dashboard"
- "traefik.frontend.headers.customresponseheaders.Access-Control-Allow-Origin=*"
configs:
- source: config.json
target: /src/Parse-Dashboard/parse-dashboard-config.json

configs:
config.json:
file: ./config.json

networks:
default:
external:
name: parse_net

The configuration defines the default username and password, and also says that the server allows a connection via HTTP. Setting INSECURE to be true is fine, as we could do SSL simply at the ingress layer, using Træfik:

{
"apps": [
{
"serverURL": "http://localhost:1337/parse",
"appId": "APP1",
"masterKey": "MASTER_KEY",
"appName": "APP1",
"iconName": "MyAppIcon.png",
"supportedPushLocales": ["en", "ru", "fr"]
}
],
"users": [
{
"user":"admin",
"pass":"password"
}
],
"iconsFolder": "icons",
"allowInsecureHTTP": true
}

The following YAML code is to define the L7 Træfik ingress for Parse and Parse dashboard. We have to expose Parse to the outside too, as the dashboard is a fat client, rather than server-side rendering. This is the main reason we need to set Allow-Origin=*:

version: '3.3'

services:

l7:
image: traefik:1.5.2
command: --docker
--docker.swarmmode
--docker.watch
--docker.endpoint=tcp://docker-api:2375
--entryPoints="Name:parse_server Address::1337"
--entryPoints="Name:parse_dashboard Address::4040"
--web --logLevel=DEBUG
ports:
- published: 1337
target: 1337
protocol: tcp
mode: host
- published: 4040
target: 4040
protocol: tcp
mode: host

networks:
default:
external:
name: parse_net

If everything goes well, we can open our favorite browser and navigate to localhost:4040 for the Parse dashboard, as shown in the following screenshot. The default Username and Password are: admin/password:

Figure 8.2: The login page of the Parse dashboard

Here, in the following screenshot, the dashboard of our Parse platform APP1 connects to the Parse instance at http://localhost:1337:

Figure 8.3: The Parse application screen showing the core part
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset