1

I'm trying to deploy a simple node and mysql server/database with elastic beanstalk. I've successfully containerized the app so I know my docker-compose.yml file is working. Now I'm trying to convert that file to a Dockerrun.aws.json file and deploy using elastic beanstalk. I get the same error everytime I use eb create which is: ERROR No ecs task definition (or empty definition file) found in environment

So first I tried writing this dockerrun.aws.json file manually, but to no avail. Then I found the container-transform package which supposedly converts these files to different formats. I had a coworker run it for me since I have issues with certain packages referring to python2.7 default on mac instead of 3. Anyways, I then used this file that container-transform gave me and modified a few values to match other examples of dockerrun.aws.json files I've seen, such as memory allotment, and the correct images.

This is my dockerrun.aws.json file:

{
  "AWSEBDockerrunVersion": 2,
  "containerDefinitions": [
      {
          "environment": [
              {
                  "name": "NODE_ENV",
                  "value": "${NODE_ENV}"
              },
              {
                  "name": "MYSQL_URI",
                  "value": "${mysqlcontainer}"
              }
          ],
          "essential": true,
          "image": "node:latest",
          "links": [
              "mysqlcontainer"
          ],
          "memory": 512,
          "name": "fec-api",
          "mountPoints": [
            {
                "containerPath": "/var/lib/mysql",
                "sourceVolume": "My-Db"
            }
          ],
          "portMappings": [
              {
                  "containerPort": 3000,
                  "hostPort": 3000
              }
          ]
      },
      {
          "environment": [
              {
                  "name": "MYSQL_DATABASE",
                  "value": "fec2"
              },
              {
                  "name": "MYSQL_USER",
                  "value": "fec"
              },
              {
                  "name": "MYSQL_PASSWORD",
                  "value": "fecpassword"
              },
              {
                  "name": "MYSQL_ROOT_PASSWORD",
                  "value": "rootpassword"
              }
          ],
          "essential": true,
          "image": "mysql:5.7",
          "memory": 512,
          "mountPoints": [
              {
                  "containerPath": "/var/lib/mysql",
                  "sourceVolume": "My-Db"
              }
          ],
          "name": "mysqlcontainer",
          "portMappings": [
              {
                  "containerPort": 3306,
                  "hostPort": 4306
              }
          ]
      }
  ],
  "family": "",
  "volumes": [
      {
          "host": {
              "sourcePath": "my-db"
          },
          "name": "My-Db"
      }
  ]
}

This is my docker-compose.yml file, which works locally:

version: '3'
services:
  mysqlcontainer:
    container_name: mysqlcontainer
    build: ./db/
    # image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: 'fec2'
      MYSQL_USER: 'fec'
      MYSQL_PASSWORD: 'fecpassword'
      MYSQL_ROOT_PASSWORD: 'rootpassword'
    ports:
      - '4306:3306'
    # expose:
    #   - '3306'
      # Where our data will be persisted
    volumes:
      - my-db:/var/lib/mysql
      # - /usr/src/init:/docker-entrypoint-initdb.d/
  fec-api:
    container_name: fec-api
    build: ./server/
    ports:
      - '3000:3000' # expose ports - HOST:CONTAINER
    environment:
      - NODE_ENV=${NODE_ENV}
      - MYSQL_URI=${mysqlcontainer}
    depends_on:
      - "mysqlcontainer"
    links: 
      - "mysqlcontainer"
volumes:
  my-db:

I expected to get a green checkmark on the elastic beanstalk dashboard after running eb init and eb create. When I run eb init, it does recognize that I have docker configurations so it must know I have the dockerrun.aws.json file in the root directory, but when I eb create I get the error. Any idea how to diagnose this issue, or how to properly compose the docker-compose.yml equivalent for the dockerrun.aws.json file?

Srujan
  • 21
  • 4

0 Answers0