This project meant to explain in an easy way how to:
- Make a dockerized CI/CD pipeline with circle CI
- Deploy the application to Heroku using Github as VCS
- Solves the "work on my machine" issue, guaranteeing that every environment is the same, ie, dev and prod environment will use the same flavor of java in the same OS.
- Allows deploying in any platform from bare metal to the cloud with minimum configuration.
- A Github account
- Open a Circle CI account associated to the Github account created in the first step
- Open a Heroku account, also install the Heroku CLI for your computer.
- The code to deploy, for this example we are using a simple spring boot application generated by start.spring.io
- In the root of your project create a folder named .circleci
- In the .circleci folder add the configuration file config.yml for your pipeline you can check the example made for this project here
- Just push the code and review the pipeline in your CircleCI dashboard ๐
- CircleCI Workflow has a different environment to each step if you want that the info of one step available for other, you need to use the workspace feature
- To be able to deploy to Heroku you need to define the project environment variables HEROKU_APP_NAME and HEROKU_API_KEY. you can achieve this with environment variable feature, Is a safe way to store sensitive information to be used during the pipeline execution
- To obtain the HEROKU_API_KEY value you need to execute locally
heroku auth:token
- Heroku uses the port 80 to expose the app, if the app is deployed using docker you must add a line in the application.properties file, the spring configuration will set as default the port 8080 if the $PORT environment variable isn't defined
- We use 2 docker images
- Dockerfile: run the Compile and Test steps.
- Dockerfile.runtime: A multistage Dockerfile that is responsible for the Package and Deploy steps.
For further reference, please consider the following sections: