-
sudo apt-get update
-
Check if java is installed by running
java
-
If java isn't installed:
sudo apt install default-jdk
-
sudo curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
-
sudo systemctl enable docker
-
docker —version
(Optional to verify installation)
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
(Optional to verify installation)
- From a separate local bash instance run:
scp -i "your_pem.pem" /your/fat/jar/path/file-shadow.tar ubuntu@ec2-xx-xx-xx.compute-1.amazonaws.com:~/shadow.tar
(pay attention is a tar file) - Now get back to your server bash instance and run :
tar -xvf ./shadow.tar
- Now navigate inside the created folder, and into
lib
which is where your fat.jar
is located at.
nano Dockerfile
(at the location of your fat jar) add the following content, and save:
FROM openjdk:latest
COPY ./your_fat_jar_name.jar fat.jar
EXPOSE your_vertx_server_port
ENTRYPOINT java -jar fat.jar
sudo docker build -t choose_your_docker_image_name .
(pay attention to the.
at the end)
nano docker-compose.yml
(at the location of your fat jar) add the following content, and save:
version: "3.3"
services:
choose_your_service_name:
restart: always
image: your_docker_image_name
container_name: choose_your_container_name
ports:
- "choose_exposed_port_normally_80:your_vertx_server_port"
sudo docker-compose up -d