2

I'm trying to deploy my application using Multi Container Dockerrun.aws.json file. At first I created docker image to my application using this Dockerfile.

FROM amazoncorretto:17
ARG JAR=target/peaksoft-lms-backend-0.0.1-SNAPSHOT.jar
COPY ${JAR} app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
EXPOSE 8000

And pushed to docker hub and trying to create docker-compose.yml file with database Postgres

version: '3.8'
services:
  backend:
    image: 'beksultancs/peaksoftlms:1.0.1'
    ports:
      - 80:8000
    depends_on:
      - postgres
    environment:
      - SPRING_PROFILES_ACTIVE=dev
      - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/peaksoftdb
      - SPRING_DATASOURCE_USERNAME=user
      - SPRING_DATASOURCE_PASSWORD=pass
      - SPRING_JPA_HIBERNATE_DDL-AUTO=create
    restart: "always"
  postgres:
    image: 'postgres:13-alpine'
    ports:
      - 5432:5432
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass
      - POSTGRES_DB=peaksoftdb

and tested docker-compose.yml file using command

docker-compose up --build

It works perfectly!

And I wanted to deploy this multi-container app to AWS Elastic Beanstalk

I created new environment using platform 'Docker running on 64bit Amazon Linux 2/3.4.17' and upload my compose file* It didn't work. Cannot find reason :(

And Tried to deploy application using Dockerrun.aws.json file!

    {
      "AWSEBDockerrunVersion": 2,
      "containerDefinitions": [
        {
          "name": "backend",
          "image": "beksultancs/peaksoftlms:1.0.1",
          "essentials": true,
          "memory": 1024,
          "portMappings": [
            {
              "hostPort": 80,
              "containerPort": 8000
            }
          ],
          "links": [
            "postgres"
          ],
          "environment": [
            {
              "name": "SPRING_PROFILES_ACTIVE",
              "value": "dev"
            },
            {
              "name": "SPRING_DATASOURCE_URL",
              "value": "jdbc:postgresql://postgres:5432/peaksoftdb"
            },
            {
              "name": "SPRING_DATASOURCE_USERNAME",
              "value": "user"
            },
            {
              "name": "SPRING_DATASOURCE_PASSWORD",
              "value": "pass"
            },
            {
              "name": "SPRING_JPA_HIBERNATE_DDL-AUTO",
              "value": "create"
            }
          ]
        },
        {
          "name": "postgres",
          "image": "postgres:13-alpine",
          "essentials": true,
          "memory": 256,
          "portMappings": [
            {
              "hostPort": 5432,
              "containerPort": 5432
            }
          ],
          "environment": [
            {
              "name": "POSTGRES_USER",
              "value": "user"
            },
            {
              "name": "POSTGRES_PASSWORD",
              "value": "pass"
            },
            {
              "name": "POSTGRES_DB",
              "value": "peaksoftdb"
            }
          ]
        }
      ]
    }

I create new environment using platform 'ECS running on 64bit Amazon Linux 2/3.1.3' and upload this .json file. It also didn't work :(

What I did wrong? Or What should I do to deploy this multi-container app to AWS Elastic Beanstalk? Thanks!

Philippe Remy
  • 2,967
  • 4
  • 25
  • 39
Beksultan
  • 59
  • 1
  • 3

0 Answers0