Migrate a Heroku Java Application to a Platform.sh service.
You will need:
- an active application on Platform.sh configured to an empty database
- an active application on Heroku
1. Git clone the Heroku Repository
git clone heroku_repository.git
2. Create the three basic Platform.sh file
.platform/routes.yaml: Platform.sh allows you to define the routes.
.platform/services.yaml: Platform.sh allows you to completely define and configure the topology and services you want to use on your project.
.platform.app.yaml: You control your application and the way it will be built and deployed on Platform.sh via a single configuration file.
3. Set the Application File
.platform.app.yaml we’ll set the minimum configuration to run a plain configuration be aware that it does not include database services such as MySQL, MariaDB and so on.
# This file describes an application. You can have multiple applications # in the same project. # # See https://docs.platform.sh/user_guide/reference/platform-app-yaml.html # The name of this app. Must be unique within a project. name: app # The runtime the application uses. type: 'java:8' disk: 1024 # The hooks executed at various points in the lifecycle of the application. hooks: build: mvn clean install mounts: 'server/': source: local source_path: server_source # The relationships of the application with services or other applications. # # The left-hand side is the name of the relationship as it will be exposed # to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand # side is in the form `<service name>:<endpoint name>`. # The configuration of app when it is exposed to the web. web: commands: start: | cp target/dependency/webapp-runner.jar server/webapp-runner.jar cp target/tomcat.war server/tomcat.war cd server && java -jar -Xmx$(jq .info.limits.memory /run/config.json)m -XX:+ExitOnOutOfMemoryError webapp-runner.jar --port $PORT tomcat.war
4. Add Platform.sh Remote Repository
git remote add platform platform_repository.git
5. Push the changes to the Repository
git push platform master
By adding a
.platform.app.yaml file to a project, a Java application’s build process can be migrated from Heroku. In order to fully migrate, the next step is to use the Heroku CLI to dump your database and import it to a service defined on your Platform.sh project.