Deploying Trains Server: Google Cloud Platform
Deploy Trains Server on the Google Cloud Platform (GCP) using use one of our pre-built GCP Custom Images. Trains provides custom images for each released version of Trains Server. For a list of our pre-built custom images, see Released versions.
After deploying Trains Server, configure the Trains Python Client for it, see Configuring Trains for Trains Server.
Default Trains Server service ports
After deploying Trains Server, the services expose the following node ports:
- Web server on 8080.
- API server on 8008.
- File Server on 8081.
Default Trains Server storage paths
The persistent storage configuration:
- MongoDB: /opt/trains/data/mongo/
- Elasticsearch: /opt/trains/data/elastic/
- File Server: /mnt/fileserver/
Importing the Custom Image to your GCP account
Before launching an instance using a Trains Server GCP Custom Image, import the image to your custom images list.
No upload of the image file is required
We provide links to image files stored in Google Storage.
To import the image to your custom images list:
- In the Cloud Console, go to the Images page.
- At the top of the page, click Create image.
- In Name, specify a unique name for the image.
- Optionally, specify an image family for your new image, or configure specific encryption settings for the image.
- In the Source menu, select Cloud Storage file.
- Enter the Trains Server image bucket path (see Released versions), for example: allegro-files/trains-server/trains-server.tar.gz
- Click Create to import the image. The process can take several minutes depending on the size of the boot disk image.
By default, Trains Server deploys as an open network. To restrict Trains Server access, follow the instructions in the Securing deployment section, on the "Configuring Trains Server" page.
To launch Trains Server using a GCP Custom Image, see the Manually importing virtual disks in the "Google Cloud Storage" documentation, Compute Engine documentation. For more information on Custom Images, see Custom Images in the "Compute Engine documentation".
The minimum requirements for Trains Server are:
- 2 vCPUs
- 7.5GB RAM
Network and security
Ensure your instance is properly secured. If not specifically set, a GCP instance will use default firewall rules that allow public access to various ports. If your instance is open for public access, we recommend that you follow best practices for access management, including:
- Only allow access to the specific ports used by Trains Server (see Default Trains Server Service ports). If HTTPS access is configured for your instance, allow access to port 443.
- Configure Trains Server to use fixed user names and passwords (see Web Login Authentication)
To restart your Trains Server Docker deployment:
- To restart Trains Server, first stop and then restart the Docker containers by executing the following commands:
docker-compose -f /opt/trains/docker-compose.yml down docker-compose -f /opt/trains/docker-compose.yml up -d
To upgrade your Trains Server Docker deployment:
- Shut down the docker containers. Execute the following command:
docker-compose -f docker-compose.yml down
We recommend backing up your data and, if your configuration folder is not empty, backing up your configuration.
If your data and configuration folders are in /opt/trains, then archive all data into ~/trains_backup_data.tgz, and your configuration into ~/trains_backup_config.tgz:
- backup your data and configuration.
sudo tar czvf ~/trains_backup_data.tgz -C /opt/trains/data . sudo tar czvf ~/trains_backup_config.tgz -C /opt/trains/config .
- restore your data and configuration.
sudo rm -fR /opt/trains/data/* /opt/trains/config/* sudo tar -xzf ~/trains_backup_data.tgz -C /opt/trains/data sudo tar -xzf ~/trains_backup_config.tgz -C /opt/trains/config
- backup your data and configuration.
- Download the latest docker-compose.yml file.
curl https://raw.githubusercontent.com/allegroai/trains-server/master/docker-compose.yml -o /opt/trains/docker-compose.yml
- Spin up the docker containers. This automatically pulls the latest Trains Server build.
docker-compose -f /opt/trains/docker-compose.yml pull docker-compose -f /opt/trains/docker-compose.yml up -d
If issues arise during your upgrade, see the FAQ page, How do I fix Docker upgrade errors?.
Examples and use cases
The following a section contains a list of Custom Image URLs (exported in different formats) for each released Trains Server version.
Latest version - v0.15
All release versions
- v0.15.1 - https://storage.googleapis.com/allegro-files/trains-server/trains-server-0-15-1.tar.gz
- v0.15.0 - https://storage.googleapis.com/allegro-files/trains-server/trains-server-0-15-0.tar.gz
- v0.14.1 - https://storage.googleapis.com/allegro-files/trains-server/trains-server-0-14-1.tar.gz