Deploying to Clever Cloud
Clever cloud is an IT Automation platform
Before you start
You must install the Clever cloud CLI.
You must also create a Clever Cloud account and log in with the CLI by running the following command clever login
Opening https://console.clever-cloud.com/cli-oauth?cli_version=2.7.1&cli_token=XXX in your browser to log you in…
Login successful as ...
Create your Clever Cloud application
-
If you are using maven
clever create --type maven [your application name]
or using gradleclever create --type gradle [your application name]
-
Add a database addon to your application
clever addon create [addon provider] [your addon name] --link [your application name]
List supported addon providers
clever addon providers
cellar-addon Cellar S3 storage S3-like online file storage web service
config-provider Configuration provider Expose configuration to your applications (via environment variables)
es-addon Elastic Stack Elasticsearch with Kibana and APM server as options
fs-bucket FS Buckets Persistent file system for your application
mongodb-addon MongoDB A noSQL document-oriented database
mysql-addon MySQL An open source relational database management system
postgresql-addon PostgreSQL A powerful, open source object-relational database system
redis-addon Redis Redis by Clever Cloud is an in-memory key-value data store, powered by Clever Cloud -
Setup env var
clever env set CC_PRE_RUN_HOOK "cp ./clevercloud/application-clevercloud.yml ./application-prod.yml"
-
Enable dedicated build
clever scale --build-flavor M
Configure your JHipster application
-
Add a
clevercloud/
folder in your project. -
create
clevercloud/application-clevercloud.yml
for using predefined clever cloud addon env varFor PostgreSQL
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://${POSTGRESQL_ADDON_HOST}:${POSTGRESQL_ADDON_PORT}/${POSTGRESQL_ADDON_DB}?useUnicode=true&characterEncoding=utf8&useSSL=false
username: ${POSTGRESQL_ADDON_USER}
password: ${POSTGRESQL_ADDON_PASSWORD}
hikari:
maximumPoolSize: 2For MySQL
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://${MYSQL_ADDON_HOST}:${MYSQL_ADDON_PORT}/${MYSQL_ADDON_DB}?useUnicode=true&characterEncoding=utf8&useSSL=false
username: ${MYSQL_ADDON_USER}
password: ${MYSQL_ADDON_PASSWORD}
hikari:
maximumPoolSize: 2For MongoDB
spring:
data:
mongodb:
uri: ${MONGODB_ADDON_URI}
database: ${MONGODB_ADDON_DB} -
add a json file that contain the goal field to indicate how to start your application
For maven
create clevercloud/maven.json
file and using your pom.xml artifactId
{
"build": {
"type": "maven",
"goal": "-Pprod package -DskipTests"
},
"deploy": {
"jarName": "./target/[REPLACE BY ARTIFACTID]-0.0.1-SNAPSHOT.jar"
}
}
For gradle
create clevercloud/gradle.json
file and using gradle.properties rootProject.name
{
"build": {
"type": "gradle",
"goal": "-Pprod bootJar -x test"
},
"deploy": {
"jarName": "./build/libs/[REPLACE BY rootProject.name]-0.0.1-SNAPSHOT.jar"
}
}
Deploy your application
Using CLI
You must commit before deploy
git commit -m "Clever deploy"
then run:
clever deploy
Using gitlab CI
define $CLEVER_TOKEN
and CLEVER_SECRET
to gitlab CI/CD environment variables
add this stage to your .gitlab-ci.yml
deploy-to-clever-env:
stage: deploy
variables:
APP_NAME: [clever cloud app name]
APP_ID: [clever cloud app id]
script:
- wget https://clever-tools.cellar.services.clever-cloud.com/releases/latest/clever-tools-latest_linux.tar.gz
- tar xvzf clever-tools-latest_linux.tar.gz
- ./clever-tools-latest_linux/clever login --token $CLEVER_TOKEN --secret $CLEVER_SECRET
- ./clever-tools-latest_linux/clever link ${APP_ID}
- ./clever-tools-latest_linux/clever deploy -a ${APP_NAME}
environment:
name: [env name]
url: https://${APP_NAME}.cleverapps.io
Using Github Action
define CLEVER_TOKEN
and CLEVER_SECRET
to Github secret (Settings > Secret)
add this step to your .github-action.yml
- uses: actions/checkout@v2
- name: Deploy on cc
env:
APP_NAME:[clever cloud app name]
APP_ID: [clever cloud app id]
run: |
git fetch --prune --unshallow
wget https://clever-tools.cellar.services.clever-cloud.com/releases/latest/clever-tools-latest_linux.tar.gz
tar xvzf clever-tools-latest_linux.tar.gz
./clever-tools-latest_linux/clever login --token ${{ secrets.CLEVER_TOKEN }} --secret ${{ secrets.CLEVER_SECRET }}
./clever-tools-latest_linux/clever link ${{ env.APP_ID }}
./clever-tools-latest_linux/clever deploy -f -a ${{ env.APP_NAME }}
Changing the Java version
You can select the Java version (Java 11 by default)
clever env set CC_JAVA_VERSION 12