0

So I have been trying to figure this out for a while now. I am working with node and next.js, to implement WEBRTC using socket.io. I containerized my project and it runs fine on my local machine, I uploaded it on ec2 by watching a youtube tutorial, and whenever I run the task/container it stops with these logs results. says cannot find 'pages' directory which i did initialize in compose file.

my root directory

log results

docker-compose.yml

version: '3'

services:
 app:
   image: webrtc
   build: .
   ports:
     - 3000:3000
   volumes:
     - ./pages:/app/pages
     - ./public:/app/public
     - ./styles:/app/styles
     - ./hooks:/app/hooks

Dockerfile

FROM node:16-alpine

WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn install

COPY next.config.js ./next.config.js

CMD ["yarn", "dev"]
zayant21
  • 19
  • 7
  • If you're trying to run this on an EC2 instance or somewhere remote, are you sure you're copying all of the content you need to the remote host? Can you `COPY` the application files into the image rather than injecting them with `volumes:`? I see you've included a couple of the PNG asset files you're trying to serve, but it might clarify the question to remove these and replace them with the plain-text logs from your application. – David Maze Nov 13 '22 at 11:42

1 Answers1

0

I think you need to COPY the whole directory incl. "pages", currently you're only copying the config and the project files... Instead of COPY next.config.js ./next.config.js try COPY . . if feasible.

Otherwise if it's required using docker-compose with the volumes make sure the mapping to EFS is set up correctly: https://docs.docker.com/cloud/ecs-compose-features/#persistent-volumes This would be a related matter then: How to mount EFS inside a docker container?

8njmn
  • 81
  • 3