0

I am trying to develop a sample Spring Boot microservice using PostgreSQL database connection. And I need to deploy it into AWS ECS container service. My doubt is that I need to build image for Java + PostgreSQL, and I need to push into AWS ECS repository.

How I can merge both Java and PostgreSQL base images into one using my Dockerfile? I only used java:8 at FROM clause in the Dockerfile. I need to build one Docker image for both Java + PostgreSQL.

1 Answer 1

2

It seems that you can put everything in a single Dockerfile using multi-stage builds.

But I would do two separate containers and deploy two separated services so when you want to deploy it in production mode you don't need to change anything.

Have you taken in account that data is not persistent within the container? I mean, if you put Postgres on a container the data will be lost when you restart the container. You can use a volume to persist the data and store it on the container host instance.

If you are not going to use ECS autoscaling, I would deploy this on an EC2 instance with docker-compose, using a volume to store the Postgres data and then if you need to move to ECS, host Postgres in an external host and connect from the ECS cluster to it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.