Installation
Installing OpenC3 COSMOS
The following sections describe how to get OpenC3 COSMOS installed on various operating systems. This document should help you setup you host machine to allow you to have a running version of COSMOS in no time.
Installing OpenC3 COSMOS on Host Machines
Installation Video for macOS
Prerequisites
If you're on Linux (recommended for production), we recommend installing Docker using the Install Docker Engine instructions (do not use Docker Desktop on Linux). Note: Red Hat users should read the Podman documentation. If you're on Windows or Mac, install Docker Desktop. All platforms also need to install Docker Compose.
-
Minimum Resources allocated to Docker: 8GB RAM, 1 CPU, 80GB Disk
-
Recommended Resources allocated to Docker: 16GB RAM, 2+ CPUs, 100GB Disk
-
Docker on Windows with WSL2:
-
WSL2 consumes 50% of total memory on Windows or 8GB, whichever is less. However, on Windows builds before 20175 (use
winverto check) it consumes 80% of your total memory. This can have a negative effect on Windows performance! -
On Windows builds < 20175 or for more fine grained control, create C:\Users\<username>\.wslconfig. Suggested contents on a 32GB machine (increase memory as needed):
[wsl2]
memory=16GB
swap=0
-
Docker by default will break idle (no data) connections after a period of 5 minutes. This "feature" will eventually cause you problems if you don't adjust the Docker settings. This may manifest as idle connections dropping or simply failing to resume after data should have started flowing again. Find the file at C:\Users\username\AppData\Roaming\Docker\settings.json on Windows or ~/Library/Group Containers/group.com.docker/settings.json on MacOS. Modify the value vpnKitMaxPortIdleTime to change the timeout (recommend setting to 0). Note: 0 means no timeout (idle connections not dropped)
Note: As of December 2021 the COSMOS Docker containers are based on the Alpine Docker image.
Clone Project
We recommend using the COSMOS project template to get started.
git clone https://github.com/OpenC3/cosmos-project.git
git clone https://github.com/OpenC3/cosmos-enterprise-project.git
If you need to install in an offline environment you should first see if you're able to directly use the COSMOS containers. If so you can first save the containers:
./openc3.sh util save docker.io openc3inc 5.16.2
This will download the COSMOS containers from the docker.io repo using the openc3inc namespace and version 5.16.2. The repo, namespace and version are all configurable. Tar files are created in the 'tmp' directory which you can transfer to your offline environment. Transfer the tar files to your offline environment's project 'tmp' dir and import them with:
./openc3.sh util load 5.16.2
Note the version specified in save needs to match the version in load.
Certificates
The COSMOS containers are designed to work and be built in the presence of an SSL Decryption device. To support this a cacert.pem file can be placed at the base of the COSMOS project that includes any certificates needed by your organization. Note: If you set the path to the ssl file in the SSL_CERT_FILE environment variables the openc3 setup script will copy it and place it for the docker container to load.
Increasingly organizations are using some sort of SSL decryptor device which can cause curl and other command line tools like git to have SSL certificate problems. If installation fails with messages that involve "certificate", "SSL", "self-signed", or "secure" this is the problem. IT typically sets up browsers to work correctly but not command line applications. Note that the file extension might not be .pem, it could be .pem, crt, .ca-bundle, .cer, .p7b, .p7s, or potentially something else.
The workaround is to get a proper local certificate file from your IT department that can be used by tools like curl (for example C:\Shared\Ball.pem). Doesn't matter just somewhere with no spaces.
Then set the following environment variables to that path (ie. C:\Shared\Ball.pem)
SSL_CERT_FILE
CURL_CA_BUNDLE
REQUESTS_CA_BUNDLE
Here are some directions on environment variables in Windows: Windows Environment Variables
You will need to create new ones with the names above and set their value to the full path to the certificate file.
Run
Add the locally cloned project directory to your path so you can directly use the batch file or shell script. In Windows this would be adding "C:\cosmos-project" to the PATH. In Linux you would edit your shell's rc file and export the PATH. For example, on a Mac add the following to ~/.zshrc: export PATH=~/cosmos-project:$PATH.
Run openc3.bat run (Windows), or ./openc3.sh run (linux/Mac).
Note, you can edit the .env file and change OPENC3_TAG to a specific release (e.g. 5.0.9) rather than 'latest'.
If you see an error indicating docker daemon is not running ensure Docker and Docker compose is installed and running. If it errors please try to run docker --version or docker-compose --version and try to run the start command again. If the error continues please include the version in your issue if you choose to create one.
Running docker ps can help show the running containers.
openc3.* takes multiple arguments. Run with no arguments for help. An example run of openc3.sh with no arguments will show a usage guide.
./openc3.sh
Usage: ./openc3.sh [cli, cliroot, start, stop, cleanup, run, util]
* cli: run a cli command as the default user ('cli help' for more info)
* cliroot: run a cli command as the root user ('cli help' for more info)
* start: start the docker-compose openc3
* stop: stop the running dockers for openc3
* cleanup: cleanup network and volumes for openc3
* run: run the prebuilt containers for openc3
* util: various helper commands
Connect
Connect a web browser to http://localhost:2900. Set the password to whatever you want.
Next Steps
Continue to Getting Started.
Stop COSMOS
The below command will stop all running COSMOS containers. This will not remove Docker volumes and data, and will be preserved after stopping. If COSMOS is restarted using the ./openc3.sh run command, the data will remain intact.
./openc3.sh stop
Resume COSMOS
COSMOS can be started up again with the run command, with previously used data intact (if any). If there are previously used Docker volumes and data available, COSMOS will start up using that data. If COSMOS is used with Local Mode, the local configurations will be referenced and used. If this is a first time deploy, the run command will begin with a fresh installation.
./openc3.sh run
Cleanup COSMOS
If you need to remove COSMOS from your system or reset your installation, follow these steps.
The --help option on the ./openc3.sh command will provide helpful guidance of the available options and further descriptions. Example below:
❯ ./openc3.sh cleanup --help
Usage: ./openc3.sh cleanup [local] [force]
Remove all COSMOS Core docker volumes and data.
WARNING: This is a destructive operation that removes ALL COSMOS Core data!
Arguments:
local Also remove local plugin files in plugins/DEFAULT/
force Skip confirmation prompt
Examples:
./openc3.sh cleanup # Remove volumes (with confirmation)
./openc3.sh cleanup force # Remove volumes (no confirmation)
./openc3.sh cleanup local # Remove volumes and local plugins
./openc3.sh cleanup local force # Remove volumes and local plugins (no confirmation)
Options:
-h, --help Show this help message
To remove Docker networks, volumes, and data
To cleanup Docker volumes and data created by COSMOS:
./openc3.sh cleanup
The cleanup command will remove all Docker volumes, which means all your COSMOS data will be permanently deleted. Make sure to backup any important data before running cleanup.
To remove Docker networks, volumes, data, and Local Mode changes
If you're running COSMOS with Local Mode, you may notice that modified files and newly created files are added to your host machine, under the plugins directory in your repository. Files are synced between server and local file system, which eliminates the need for rebuilding & re-uploading a plugin for development. If you want these local changes to also be cleaned up, run the following:
./openc3.sh cleanup local
The cleanup command will remove all Docker volumes, which means all your COSMOS data will be permanently deleted, including local mode changes added to your host machine. Make sure to backup any important data before running cleanup.
To remove Docker networks, volumes, and data without confirmation
The cleanup options will prompt for a confirmation as they are going to delete your COSMOS installation. If you'd like to skip the confirmation, run the following:
./openc3.sh cleanup force
or
./openc3.sh cleanup local force
The force option will remove containers, networks, volumes, and data without user confirmation.
Remove Docker Images (Optional)
If you want to free up disk space by removing the COSMOS Docker images:
docker images | grep openc3inc | awk '{print $3}' | xargs docker rmi
Or to remove all unused Docker images:
docker image prune -a
With -a flag: The command docker image prune -a is more aggressive and removes all unused images, meaning any image that is not currently associated with a running or stopped container. Use this with caution, as it might remove base images you want to keep.
Feedback
Please create an issue on GitHub describing what we can do to make it better.