tryingCode
tryingCode

Reputation: 21

Elastic Beanstalk in AWS is only using my Dockerfile, not my Docker Compose file

I want Elastic Beanstalk to call my docker-compose file when running the EC2 instance in order to spin up redis within the docker container. It is not doing so. When I run the docker-compose file using a script outside of AWS my application runs just fine. I have looked at the documentation on AWS and there isn't a clear answer on how EB is actually finding my docker compose file. I would love to ask anyone with a bit more experience for advice on how to remedy this.

docker-compose

version: '3'
services:
  web:
    image: filamentgraphql/filament-prod
    container_name: 'filament-prod-hot'
    ports: 
      - '4000:4000'
    volumes:
      - .:/usr/src/app
    command: npm run build
  redis-server:
    image: 'redis'
    volumes:
      - "./data/redis:/usr/src/app/data"


Dockerfile

FROM node:12.16.1
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install
RUN npm run build
EXPOSE 4000
ENTRYPOINT node ./server/server.js

Upvotes: 0

Views: 2258

Answers (2)

equivalent8
equivalent8

Reputation: 14227

this will work

version: '3'
services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    image: filamentgraphql/filament-prod
    container_name: 'filament-prod-hot'
    ports: 
      - '4000:4000'
    volumes:
      - .:/usr/src/app
    command: npm run build
  redis-server:
    image: 'redis'
    volumes:
      - "./data/redis:/usr/src/app/data"

...but it will rebuild your docker container twice. To get around this may as well rename your Dockerfile to Dockerfile-aws and do

    build:
      context: .
      dockerfile: Dockerfile-aws

Upvotes: 0

Marcin
Marcin

Reputation: 238199

I think the options are explosive as I read the AWS docs:

You can deploy your web application as a containerized service to Elastic Beanstalk by doing one of the following actions:

  • docker-compose.yml
  • Dockerfile

If you want to keep using Dockerfile for your docker-compose.yml, rename it or place it in some subfolder so that EB does not find the Dockerfile

Upvotes: 1

Related Questions