Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bootstrapping #1

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env

This file was deleted.

59 changes: 59 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
###################################################################################################
# Generic Settings (devices, sso, market, account)
###################################################################################################

MYCROFT_DOMAIN=asdf.asdf
SSO_BASE_URL=sso.asdf.asdf
OAUTH_BASE_URL=sso.asdf.asdf

SELENE_ENVIRONMENT=prod

DB_HOST=db
DB_NAME=mycroft
DB_PORT=5432
DB_USER=selene

REDIS_HOST=redis
REDIS_PORT=6379

###################################################################################################
# Market API Skills Setup (skills_setup)
###################################################################################################

GITHUB_USER=<todo>
GITHUB_PASSWORD=<todo>

###################################################################################################
# Device API (devices)
###################################################################################################

EMAIL_SERVICE_HOST=
EMAIL_SERVICE_PORT=
EMAIL_SERVICE_USER=
EMAIL_SERVICE_PASSWORD=

# The speech to text engine requires a key to Google's STT API.
GOOGLE_STT_KEY=

# The weather skill requires a key to the Open Weather Map API
OWM_KEY=
OWM_URL=https://api.openweathermap.org/data/2.5

# The Wolfram Alpha skill requires an API key to the Wolfram Alpha API
WOLFRAM_ALPHA_KEY=
WOLFRAM_ALPHA_URL=https://api.wolframalpha.com

###################################################################################################
# Single Sign On API (sso)
###################################################################################################

# The password reset functionality sends an email to the user with a link to reset their password.
# Selene uses SendGrid to send these emails so a SendGrid account and API key are required.
SENDGRID_API_KEY=

# Access to the Github API is required to support logging in with your Github account.
# Details can be found here <https://developer.github.com/v3/guides/basics-of-authentication/>
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=


3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
storage
generated
generated
84 changes: 72 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Heavily based on the original repo by Dimitris Karakasilis (jimmykarily) at http

## Goal

Deploy an offline home assistant server as easely as possible.
Deploy an offline home assistant server as easily as possible.

## Why

Expand All @@ -21,20 +21,80 @@ The project that is closer to the desired result is Mycroft (https://mycroft.ai/
- Internet connection to download docker images and dependencies
- A good CPU, STT AND TTS are very CPU intensive. (Using a (nvidia/CUDA ?) GPU would speed up the process a lot but I don't know if it works with this setup yet.)

## Getting started
## Prepare configuration

You can use `.env.sample` as a starting point to create your specific `.env` file.
```sh
cp .env.sample .env
```

To generate all needed passwords in `./generated` you can run:
```sh
./setup.sh (only needed once)
```

If you do not have a valid domain you can use a fake one like `asdf.asdf` as `MICROFT_DOMAIN`.

Then you should edit your `/etc/hosts` to something like that:
```
127.0.0.1 sso.asdf.asdf
127.0.0.1 account.asdf.asdf
127.0.0.1 api.asdf.asdf
127.0.0.1 market.asdf.asdf
127.0.0.1 home.asdf.asdf
127.0.0.1 asdf.asdf
```

## Start Mycroft-Backend

```sh
docker-compose up -d
```
And everything is ready to go. The setup phase can take a while.

Edit and complete :

- config.env
- config_external_accounts.env
- .env
Now you should be able to access your very own Selene Backend (i.e. browse to `https://home.asdf.asdf`)

The .env file is only used to build the images, but the variable it contains must have the same value as the one in config.env.

Run ./setup.sh (only needed once)
## Start Mycroft-Core (client)

```sh
cd ./client
docker-compose up -d
```

The host-connections of `./client/storage/mycroft.conf` are linked to the backend docker containers. If you want to start the client on a different machine you need to adjust these ones and the network link in `./client/docker-compose.yml`.

## Register Device and enjoy your personal assistant

During first startup, Mycroft-Core should tell you a pairing code. Browse to `https://home.asdf.asdf` and register your client.

After the registration you should be able to talk to Mycroft and even access Backend-APIs like WolframAlpha (if you registered a valid API-Key).


## Security hint

The reverse proxy of Microft-Backend currently uses a self-signed certificate so we needed to disable client side SSL-Verification. If you are using a reverse proxy delivering a valid certificate we strongly recommend you to re-enable SSL-Verification.

To enable SSL-Verification you simply need to remove the entire `entrypoint` section in `./client/docker-compose.yml` and rebuild the container.

## Development

After changing the domain settings in `.env` you need to clean build everything to 'burn' the new domain settings into the images

```sh
docker-compose build --no-cache --pull
```

A completely fresh startup can be achieved by

```sh
docker-compose down -v
rm -rf ./generated
./setup.sh
docker-compose build --no-cache --pull
docker-compose up -d
```

Run docker-compose up -d
And everything is ready to go. The setup phase can take a while.
## Troubleshooting

#### Problem: No skills available in the marketplace.
Expand All @@ -44,10 +104,10 @@ And everything is ready to go. The setup phase can take a while.
- Use uWSGI for both mozilla-tts and deepspeech server instead of directly exposing the flask dev server through nginx.
- Make the deepspeech server container use the mainstream repo now that it has been updated.
- core-version should not be hardcoded in docker-compose.yml (get latest somehow?)
- Add more variables to the .env files. (There are some left in docker-compose.yml)
- Make TTS and STT use the GPU. Not very difficult to do, but they seem to use CUDA and for now I do not plan on installing anything proprietary on my servers.
- Include a fix for the problems in the troubleshooting section.
- Rewrite the nginx config to expose api only on the required domains ? to make it easier to split this on multiple computers without docker swarm ?
- Use .env Variables in wakeword setup

## Note

Expand Down
27 changes: 27 additions & 0 deletions client/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3'
services:
mycroft:
image: mycroftai/docker-mycroft
restart: "on-failure"
volumes:
- ./storage:/root/.mycroft
- ${XDG_RUNTIME_DIR}/pulse/:${XDG_RUNTIME_DIR}/pulse/
- ${HOME}/.config/pulse/:/root/.config/pulse/
environment:
PULSE_SERVER: "unix:${XDG_RUNTIME_DIR}/pulse/native"
ports:
- "8181:8181"
devices:
- "/dev/snd:/dev/snd"
entrypoint:
- bash
- -c
# Deactivate ssl verification to communicate with servers having a self signed certificate
- "sed -i 's/data=data, json=json_body, timeout=(3.05, 15)/data=data, json=json_body, timeout=(3.05, 15), verify=False/' /opt/mycroft/mycroft/api/__init__.py &&
/opt/mycroft/startup.sh
"

networks:
default:
external:
name: mycroft_offline_web
15 changes: 15 additions & 0 deletions client/storage/mycroft.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"max_allowed_core_version": 20.2,
"server": {
"url": "https://selene-ui-proxy",
"version": "v1",
"update": true,
"metrics": false
},
"stt": {
"module": "deepspeech_server",
"deepspeech_server": {
"uri": "http://deepspeech:8080/stt"
}
}
}
4 changes: 0 additions & 4 deletions config.env

This file was deleted.

11 changes: 0 additions & 11 deletions config_external_accounts.env

This file was deleted.

10 changes: 7 additions & 3 deletions deepspeech/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ FROM ubuntu:18.04

# https://pypi.org/project/deepspeech-server/

RUN apt-get update && apt-get install -y python3.7 python python3-pip git wget python3.7-dev && pip3 install deepspeech && pip3 install deepspeech-server && wget https://github.com/mozilla/DeepSpeech/releases/download/v0.7.1/deepspeech-0.7.1-models.pbmm && wget https://github.com/mozilla/DeepSpeech/releases/download/v0.7.1/deepspeech-0.7.1-models.scorer
RUN wget -O config.json https://raw.githubusercontent.com/kiratsune/deepspeech-server/master/config.sample.json

RUN apt-get update && \
apt-get install -y python3.7 python python3-pip git wget python3.7-dev && \
pip3 install deepspeech && \
pip3 install deepspeech-server && \
wget https://github.com/mozilla/DeepSpeech/releases/download/v0.7.1/deepspeech-0.7.1-models.pbmm && \
wget https://github.com/mozilla/DeepSpeech/releases/download/v0.7.1/deepspeech-0.7.1-models.scorer
RUN wget -O config.json https://raw.githubusercontent.com/MainRo/deepspeech-server/master/config.sample.json
CMD ["deepspeech-server", "--config", "config.json"]
Loading