cenas

CI/CD - Integrating and Deploying Continuously

2025/06/20

We have built an API, and it is working well on our local machine. However, we now want to host the app on a server to expose the API to others. What do we need to make this happen?

The first answer that usually comes to mind is Continuous Integration and Continuous Deployment (CI/CD). But first and foremost, what tools do we actually need? Let’s take a Java Spring application as an example to show the simplest way to understand how a CI/CD pipeline works.

Steps

1 - We need to compile and build the app with a building tool (Maven, in this example).

mvn clean package

2 - Pack the final result as Docker container

docker buildx build --platform linux/amd64 -t appname .

In my case i am doing the build in a Mac OS that’s why i am targeting the build for a Linux system. But how the build is going to be done? well, we need a set of instructions, that instructions by default reside in a Dockerfile file

FROM eclipse-temurin:22-jdk-alpine
WORKDIR /app
COPY target/*.jar /app/application.jar
ENTRYPOINT ["java","-Dspring.profiles.active=dev","-jar","/app/application.jar"]

3 - Send the container to a Registry to be used by others Since we do not have a server to share docker images, we need to setup a registry in the server so we can have a place to push images:

docker run -d -p 5005:5000 --name registry registry:2

Tag the image:

docker tag appname 192.168.1.3:5005/appname:latest

Push it to the Registry:

docker push 192.168.1.3:5005/appname:latest

4 - Finally! Run the command in the server to create a Docker Container

sudo docker run -d --restart unless-stopped -p 8811:8811 --name appname 192.168.1.3:5005/appname:latest

What we did in all these steps was “Integration” and “Deployment”, we are missing the “Continuous” part.

Automate the “Integration” and “Deploy” to be … Continuous …

In the following articles i show how to do it continuously