-
Notifications
You must be signed in to change notification settings - Fork 21
Docker Usage
Ogres supports Docker environments for both production and development. A complete docker-compose.yaml is provided with commented documentation.
Three images are included: frontend, backend, and nginx. The frontend image builds the ClojureScript client application, the backend image builds the Clojure application server which exposes a WebSocket connection, and the nginx image ties together the marketing website, the client application, the application server's WebSocket connection, as well as previous Ogres releases tagged on GitHub.
-
VERSION- The release tag for the client application. Tags can be accessed with the parameterr(e.g.,/play/?r=dev). Thelatesttag is the default entrypoint for the client. Unlesslatestis specified, clients will have to use the chosen tag in order to access the Docker client build. -
MODE- Must be set to eitherreleaseorwatch. Thereleasemode will produce a production build of the client application, whereas thewatchmode will produce a developmental client build with support for hot reloading. -
SERVER_SOCKET_URL- Declares the WebSocket URL for both thefrontendandnginx. Within thefrontendimage, the URL will be the one accessed by the user's browser; in production settings you should set this to your domain (i.e.,wss://ogres.domain.com/ws). In thenginximage, this URL will point to the backend container's exposed port (i.e.,http://backend:8090/ws).
To start the environment in development mode, ensure that the MODE argument is set to watch. Then, run the following command in your terminal:
docker compose watch
The environment will start, and hot reloading will be enabled for all changes to the ClojureScript client application. Hot reloading is currently not supported for the application server.
Please note, localhost should not be used to access the client application at this time; instead, use either 127.0.0.1 or 0.0.0.0. Accessing the client with localhost will result in a blank page being displayed.
To start the environment in production mode, ensure that the MODE argument is set to release. You can also comment out the Compose line which opens port 9630 for hot reloading. Then, run the following command in your terminal:
docker compose up -d
To stop the Docker compose environment, run the following command:
docker compose stop
To delete the Docker compose environment and remove the generated images and volumes, run the following command:
docker compose down --rmi local -v
These instructions briefly describe how to run your own production instance of Ogres. In addition to docker, you will need certbot and nginx installed on the host machine for this example.
The following instructions assume you will run Ogres with a subdomain at ogres.domain.com. This is not required -- you can use a root domain.
- Start the Docker environment in production mode.
- Create the following nginx site configuration on the host machine at
/etc/nginx/sites-available/ogres.domain.com:
server {
server_name ogres.domain.com;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/ogres.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ogres.domain.com/privkey.pem;
include snippets/ssl.conf;
access_log /var/log/nginx/ogres.domain.com/access.log;
error_log /var/log/nginx/ogres.domain.com/error.log;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_http_version 1.1;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1d;
}
}
server {
server_name ogres.domain.com;
listen 80;
listen [::]:80;
return 301 https://$server_name$request_uri;
}
- Generate an SSL certificate for the subdomain with certbot. This can be completed via several methods, so please refer to the official certbot instructions for more information. The nginx configuration assumes the certificates will be installed to
/etc/letsencrypt/live/ogres.domain.com. - Link the
sites-availableconfiguration intosites-enabled:ln -s /etc/nginx/sites-available/ogres.domain.com /etc/nginx/sites-enabled/ogres.domain.com. - Reload the nginx server.
Please feel free to open a question on the discussions page.