Mr.DevEng
Mr.DevEng

Reputation: 2421

Spring Boot microservice deployment in AWS EC2 using Docker

I am trying to deploy my Spring Boot microservice using Docker containers within my EC2 machine. I have my own Ubuntu machine. I can also install Docker in my Ubuntu machine. I am not going with ECS. I need to customize my machine for Spring Boot Java deployment using Docker.

  1. Can I deploy my service using docker that installed in my machine?

  2. If that is possible in Docker, do I need to configure Tomcat/Weblogic server in my machine? Or directly in Docker only?

  3. And also can I deploy my front-end Angular 2 application in same Docker in EC2? Or I need to configure my machine for node.js/ Nginx server?

I am a beginner on AWS cloud and microservices. I still have lot of confusions in feasible deployment.

Upvotes: 0

Views: 798

Answers (1)

Benjamin Caure
Benjamin Caure

Reputation: 2403

  1. Yes of course you can deploy your service on your local machine. You should build your own docker image that contains your spring boot app. Here is the springboot how-to for the dockerfile:

    FROM openjdk:8-jdk-alpine

    VOLUME /tmp

    ARG JAR_FILE

    ADD ${JAR_FILE} app.jar

    ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

  2. You don't have to configure any container to run your springboot app if you use the fatjar approach (serverless). It's more simple if you are a beginner. By the way all the app configuration is done inside docker image, not on your machine.

  3. If you plan to use docker, I advise you to use it also for the Angular part. Angular application can be packaged inside your fatjar, this is the easiest way. To do so you you basically have to copy the "build" or "dist" directory content of your Angular app inside web-app directory of your springboot app

Upvotes: 2

Related Questions