Firstly, you need to login to the Tiny Cloud Docker registry:
$ docker login docker.tiny.cloud
It will prompt for a username, then a password:
$ Username: tiny/tiny-premium
$ Password: {the-secret-key-you-have-been-given}
Pull the image from the docker registry:
$ docker pull docker.tiny.cloud/ephox-spelling:latest
Note: it is not necessary to execute pull before executing run, but it can make any errors encountered more straightforward.
Run the docker container from the image:
$ docker run -p 18080:18080 docker.tiny.cloud/ephox-spelling:latest
2020-12-04 04:36:02.611Z [ioapp-compute-0] INFO ironbark - ironbark 2020-12-04 04:36:02.923Z [ioapp-compute-0] WARN c.e.d.config.AllowedOriginsConfig$ - No allowed-origins specified in config! 2020-12-04 04:36:02.953Z [ioapp-compute-0] INFO ironbark - ironbark config loaded successfully: IronbarkConfig(Logger[ironbark],SpellingConfig(None),OriginWhitelist(List()),None) 2020-12-04 04:36:03.718Z [scala-execution-context-global-13] INFO o.h.b.c.nio1.NIO1SocketServerGroup - Service bound to address /0.0.0.0:18080 2020-12-04 04:36:03.723Z [scala-execution-context-global-13] INFO o.h.server.blaze.BlazeServerBuilder - _ _ _ _ _ | |_| |_| |_ _ __| | | ___ | ' _| _| '_ _ _(_-< |_||___|__| .__/ |_|/__/ |_| 2020-12-04 04:36:03.804Z [scala-execution-context-global-13] INFO o.h.server.blaze.BlazeServerBuilder - http4s v0.21.3 on blaze v0.14.11 started at http://0.0.0.0:18080/
Note: Running this command will show a log warning about "allowed-origins" not being configured. This step comes later.
Environment Variables
One way to configure the docker container is to use environment variables. The default configuration file available at /ephox-spelling/ephox-spelling-docker-env.conf will substitute any known environment variables provided. The environment variables it understands are:
These environment variables can be specified individually using -e or using docker’s --env-file. As an example:
$ docker run -p 18080:18080 -e ORIGIN0=http://example.com docker.tiny.cloud/ephox-spelling:latest
See Steps 6-10 in this documentation for more details on how to supply environment variables to the service. Note, that not all configuration options are available via environment variables. For more complex configuration, your other option is to mount the configuration file when running docker.
Mounting Configuration File
Another option is to replace the existing /ephox-spelling/ephox-spelling-docker-env.conf file with your own configuration file via a docker volume mount. Assuming your configuration file is located in the current working directory and is called my-conf.conf, then, the command would be:
$ docker run -p 18080:18080 -v $(pwd)/my-conf.conf:/ephox-spelling/ephox-spelling-docker-env.conf docker.tiny.cloud/ephox-spelling:latest
Once the service is running on 18080, it should be open to receiving requests. Here are some expected outputs for the spelling service (assuming that http://good.com is in your allowed origins and http://bad.com is not)
Check if the service is running
$ curl http://localhost:18080/version
2.102.0 (for example)
Making a request to the spelling service
$ curl http://localhost:18080/1/correction -d '{"words": ["teh"], "language": "en_US"}' -H "Origin: http://good.com" -H "Content-Type: application/json"
{"spell":{ "teh":[ "tech", "eh", "the", "ate", "etch", "nth", "tether", "thee", "them", "then", "they", "tho", "thy", "tie", "toe", "Ute"]}}
Test if a request is unauthorised (wrong origin)
$ curl http://localhost:18080/1/correction -d '{"words": ["teh"], "language": "en_US"}' -H "Origin: http://bad.com" -H "Content-Type: application/json"
{ "message": "The supplied authentication is not authorized to access this resource" }
You can also test this service in the editor by configuring it in tinymce.init. If the spelling service is running locally on the default port of 18080, you would use these settings:
tinymce.init({
…,
spellchecker_rpc_url: 'http://localhost:18080',
});