TODO
The project consist of the following modules:
server
- contains code related to REST API for calculating COVID-19 risk
Make sure you have Maven
installed. Execute the following maven command from the directory of the
parent project, covid-19-risk-calculator
:
mvn clean install
It will create the Spring Boot executable JAR,server-1.0.0-SNAPSHOT.jar
, under server/target
folder.
To run the newly created Spring Boot JAR from the terminal:
java -jar server-1.0.0-SNAPSHOT.jar
This should start up the example application at port 8080
. The application can be accessed at http://localhost:8080
Before you build the Docker image, make sure Docker is available in your environment.
Execute the following maven command from the directory of the parent project, covid-19-risk-calculator
:
mvn clean install
This should build a Docker image named docker-example
.
Run the newly created Docker image, basaki/covid-19-risk-calculator-server
, by executing the
docker run
command from the terminal:
docker run --rm -p 8080:8080 --name=server basaki/covid-19-risk-calculator-server:1.0.0-SNAPSHOT
--rm
option automatically clean up the container and remove the file system when the container exit.--name
option names the Docker container asserver
. In absence of the--name
option, the Docker generates a random name for your container.-p 8080:8080
option publishes all exposed ports to the host interfaces. In our example, it is port8080
is bothhostPort
andcontainerPort
This should start up the example application and it can be accessed at http://localhost:8080
Run the docker ps
to list all the containers.
To see all running containers, execute the following command:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d19c27a9f1e basaki/covid-19-risk-calculator-server:1.0.0-SNAPSHOT "/bin/sh -c /usr/loc…" 26 seconds ago Up 24 seconds 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp server
To see all running containers including the non-running ones, execute the following command:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d19c27a9f1e basaki/covid-19-risk-calculator-server:1.0.0-SNAPSHOT "/bin/sh -c /usr/loc…" 54 seconds ago Up 53 seconds 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp server
a500ffb370c6 bitnami/kafka:2 "/opt/bitnami/script…" 4 months ago Exited (255) 3 weeks ago 0.0.0.0:9092->9092/tcp docker_kafka_1
5bae2b723042 bitnami/zookeeper:3 "/opt/bitnami/script…" 4 months ago Exited (255) 3 weeks ago 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp docker_zookeeper_1
To remove a Docker container, execute docker rm
command. This will remove a non-running container.
$ docker rm server
server
To forcefully remove a running container
$ docker rm -f server
server
To stop a container, execute docker stop
command:
$ docker server
server
To run docker compose, execute the following command from the parent
project directory, covid-19-risk-calculator
:
docker-compose up --build
This should start up the server in port 8080.
To shutdown docker compose, execute the following command:
docker-compose down