GCP Cloud Run
This tutorial will walks through the steps to create an example Form.io deployment environment on GCP Cloud Run. This tutorial assumes prior knowledge of Form.io and GCP Cloud Run.
Last updated
This tutorial will walks through the steps to create an example Form.io deployment environment on GCP Cloud Run. This tutorial assumes prior knowledge of Form.io and GCP Cloud Run.
Last updated
GCP projects serve as a "container" to organize and manage GCP services and applications.
Navigate to the GCP Console.
Log in or Create an account.
Click the Project dropdown and select Create New Project.
Input a Project name for your project.
Select (or create) an Organization.
Click the Create button.
Before a deployment can be created, a database is required to store the Form.io deployment data. MongoDB Atlas is a NoSQL database solution that will be used in this example within the GCP project to store projects, forms, and submissions.
Within the GCP Project, search and select MongoDB Atlas.
Click the Manage On Provider button, which will open cloud.mongodb.com in a new tab.
Log in or create a MongoDB account.
Select MongoDB Atlas from the Cloud Service options. If there is no organization, a new organization should be created.
Give the Organization a name and select a Cloud Service.
Add Members to the organization and click the Create Organization button.
Within the Organization, click the New Project button.
Select MongoDB Atlas from the Cloud Service options.
Give the MongoDB Project a Name.
Add any additional users to MongoDB Project through Add members.
Click the Create Project button.
A MongoDB Atlas cluster is a collection of MongoDB servers that work together to store and manage Form.io data.
Click the +Create cluster button within the MongoDB Overview page.
Select the desired Cluster Template. For this example, the M0 option will be selected.
Give the Cluster a name.
Select Google Cloud as the Provider.
Click the Create Deployment button.
Complete the following steps to connect the cluster to all required IP addresses and configure the database users.
By default, the current IP address should be added. Click the Network Access button to add any additional IP addresses. This example is set to allow any IP address to connect to the database
E.g. 0.0.0.0
Set the Username and Password for any users that will have access to the project.
Click Create Database User.
Click the Choose a connection method button.
Select Drivers as the connection option.
Ensure Node.js is selected for the Driver option.
Copy the connection string. This string will be used later as an environment variable within GCP.
The MongoDB Cluster may take some time to build before a Connection String can be copied.
Click Done to finalize the database.
Create a database to connect to the cluster by completing the following steps:
Navigate to the Cluster tab.
Click the Browse Collections for the cluster.
Click Add My Own Data button to create database.
Set a Database Name, Collection Name, then click Create.
Take note of the Database Name. It will be required in the connection string for GCP deployments. MongoDB Atlas will create a database by default called test
if a Database is not created manually.
Create a Google File Storage bucket to store file uploads and PDFs:
Navigate to the GCP Console.
Select the GCP Project.
Search and select Cloud Storage within the search bar.
Click +Create to create a bucket.
Set a name for the Bucket
Click the Create button
Check the Enforce public access setting.
Click Confirm.
Within the bucket settings, click the Settings button on the left-hand side bar.
Select the Interoperability tab.
Scroll down to the Access keys for your user account section and click Create a Key.
Record the Access key and Secret somewhere safe. They will be needed later.
Set up a GCP Cloud Run to deploy and run the containerized Form.io application in a serverless environment.
Navigate to the GCP Console.
Select your GCP Project.
Search and select Cloud Run within the search bar.
You may need to enable the Cloud Run Admin API. If so, click Enable.
Ensure Cloud Run is enabled.
Within GCP Cloud Run, click the Create Service button. This will display the service configuration screen.
Enter the formio-enterprise.io Docker container image URL within the Container image URL setting field:
docker.io/formio/formio-enterprise:9.2.0
For this tutorial, the container tag being utilized is the formio-enterprise docker image tag 9.2.0. Click Here for a list of available formio-enterprise server version tags . For the latest version, replace the version number with latest docker.io/formio/formio-enterprise:latest
Set a Service Name.
Set the Authentication method.
Set the Service Autoscaling number, the minimum recommendation is 1.
Open the Container(s), Volumes, Networking, Security tab.
Set the Container Port to 3000.
Within the Container(s), Volumes, Networking, Security settings, click the Variables and Secrets tab.
Click the +Add Variable button.
Enter the following environment variables:
For the MONGO variable, copy and paste the connection string from the database configuration step.
Update this string to include the database name of the MongoDB Cluster; in this example, the database name is formio
.
MongoDB Atlas will create a database by default called test
if a Database was not created in the previous steps. Verify the database name by navigating to the MongoDB Cluster and viewing the Collections (see screenshot below)
MONGO
The MongoDB connection string to connect to your remote database. This is the value we copied in the cluster deployment step. Ensure the correct MongoDB username, password, and database name is included in the string.
mongodb+srv://mongouser:mypassword@formiocluster.apgbu.mongodb.net/formio?retryWrites=true&w=majority&appName=FormioCluster
LICENSE_KEY
<—YOUR LICENSE—>
DEBUG
Application Logging Settings.
*.*
PORTAL_ENABLED
Used to enable the Self-Hosted Portal.
1
ADMIN_EMAIL
An admin account you would like to use as the first Admin user authenticating into the deployed environment.
admin@example.com
ADMIN_PASS
A password for the first Admin user.
CHANGEME
DB_SECRET
A secure secret that you will pick that is used to encrypt the project settings.
CHANGEME
JWT_SECRET
A secure secret that you will pick that is used to establish secure JWT tokens.
CHANGEME
PDF_SERVER
The endpoint of the GCP PDF Server deployment (created in the next section).
https://pdf-server-1234.us-central1.run.app
Add the PDF_SERVER
variable after completing the PDF deployment in GCP in the following section.
Scroll down and set the Maximum number of instances. For this example, the instance number will be set to 3.
Click the Create button. The screen should proceed to a progress screen showing the service being deployed. Once completed, the service will be deployed and will show a green checkmark.
Within GCP Cloud Run, click +Deploy Service, and select Service. This will display the service configuration screen.
Enter the Form.io pdf-server Docker container image URL in the URL settings field:
docker.io/formio/pdf-server:5.6.0
For this example, the container tag being utilized is the pdf-server docker image tag 5.6.0. Click Here for a list of available pdf-server version tags For the latest PDF version, replace with docker.io/formio/pdf-server:latest
Input a Service Name.
Set the Authentication method.
Set the Service Autoscaling number. The minimum suggested setting is 1.
Open the Container(s), Volumes, Networking, Security tab.
Set the Container Port.
Within the Container(s), Volumes, Networking, Security settings, click the Variables and Secrets tab.
Click the +Add Variable button
Enter the following Environment Variables:
For the MONGO variable, copy and paste the connection string from the database configuration step. Update this string to include the name of the MongoDB Atlas database used by the cluster; in this example, the database name is formio
.
MongoDB Atlas will create a database by default called test
if a database was not created manually in the previous steps. Verify the database name by navigating to the MongoDB Cluster and viewing the Collections (see screenshot below)
For the FORMIO_S3 variables, enter the credentials from the Google Storage Step
The application sets the FORMIO_S3_PORT
variable to 9000
by default. In this example, where FORMIO_S3_SERVER
is set to https://storage.googleapis.com
, the FORMIO_S3_PORT
environment variable should be left empty
MONGO
The MongoDB connection string to connect to your remote database. This is the value we copied before.
mongodb+srv://user:mypassword@formiocluster.apgbu.mongodb.net/formio?retryWrites=true&w=majority&appName=FormioCluster
LICENSE_KEY
The license key for your deployment. You will get this when you upgrade a project to Enterprise.
<—YOUR LICENSE—>
DEBUG
*.*
FORMIO_S3_SERVER
Storage URI of the File Storage bucket.
https://storage.googleapis.com
FORMIO_S3_BUCKET
Name of the Google bucket.
mybucket-name
FORMIO_S3_KEY
The Access Key of the Google Cloud storage bucket, found within the Interoperability tab.
ABCD1234
FORMIO_S3_SECRET
The Secret of the Google Cloud storage bucket, found within the Interoperability tab.
abc+123+def+L+ghiJKLmno
FORMIO_S3_REGION
Region of the bucket.
us-central1
FORMIO_S3_PORT
Scroll down and set the Maximum number of instances. For this example, the instance number will be set to 3.
Click the Create button.
The screen should navigate to a progress screen showing the service being deployed. Once completed, the service will be deployed and will show a green checkmark.
Copy the PDF Server URL
Within the GCP Cloud Run, add the following environment variable to the Enterprise API Deployment
PDF_SERVER
The GCP PDF Server deployment endpoint
https://pdf-server-1234.us-central1.run.app
The Cloud Run service provides a URL to access the Form.io deployment
Navigate to the GCP Console
Select your Google Cloud Project
Search and select Cloud Run within the search bar
Click on the Form.io Enterprise Server service
Click the URL link next to the service name
Login using the username and password specified in the environment variables
Create a Project.
For more information on next steps, visit the Getting Started guide
The for your deployment. You will get this when you upgrade a project to Enterprise.