CI/CD - Integrating and Deploying Continuously

We build an API, it's working well in our machine but we want to host the app in another machine that will serve the API to others, what do we need? what first comes to our mind is Continuous Integration / Continuous Deployment.
But first and foremost, what tools do we need? Let's take as an example a Java Spring App and how can we do this in the simplest way to better understand how the Continuous Integrations/Deployment works:
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"]
Specify the base image used
Set the working directory, all the subsequent docker commands will be executed in this directory
Copy the content generated by the maven command into a directory inside the container
Defines the command that will be executed when the container starts
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 ...
The next article i will talk about how to automate all of this ... here i approach the Github Actions and in the future i will use other tools like Woodpecker for example.



