In addition to Core Services, CX Cloud makes it really easy for you to deploy any Docker-based service. You just need to follow a few simple steps to deploy a service:
Make sure your project has a
Dockerfile (this is just an example):
FROM nginxCOPY html /usr/share/nginx/htmlEXPOSE 80
Create a file named
.cxcloud.yaml in the root of your project:
deployment:name: my-frontendimage:name: my-frontend-imagerepository: YOUR_AWS_ECR_REPOSITORY_URL_HEREversion: 1.1.1containerPort: 80replicas: 2env:- name: NODE_ENVvalue: production
Run CX Cloud deployment tool:
$ cxcloud deploy
Your service will be deployed to your Kubernetes cluster.
.cxcloud.yaml file has different configurable sections:
Namespace to store deployment resources
The name of your service to be saved in Kubernetes
The name of your docker image
Your AWS ECR Repository
A version to tag your docker image with
Your Dockerfile's exposed port
Number of replicas to be made (usually more than 1 just to be safe)
Standalone domain pointing to the current deployment
Which path on the domain should deployment respond to
Enable SSL for the domain
A list of environment variables that will be attached to your deployment
You can use Bash environment variables anywhere in this file. Just prefix a string with
$ to denote it:
There are a few special environment variables that are available to be used:
Full Commit ID of latest commit. eg.
Short Commit ID of latest commit. eg.
Current Git branch. eg.
For example you can set those environment variables on runtime:
$ MY_BASH_ENV=frontend cxcloud deploy
deployment.env option in the deployment manifest can be used to pass environment variables to your docker container when it's deployed to your Kubernetes cluster. This can be useful for passing things like secrets, environment config, etc.
deployment:# ...env:- name: NODE_ENVvalue: production- name: MY_SECRET_KEYvalue: $SECRET_BASH_ENV
You can pass environment variables also when running the
cxcloud deploy command:
$ cxcloud deploy -e MY_SECRET_KEY=something
You can pass multiple environment variables using commas.
If you need to assign a domain to the current deployment, you can do so in the deployment manifest under the
deployment:# ...routing:domain: service.example.compath: /ssl: false