0

The test app conforms to the following dir structure.

.
├── node_modules/
├── src/
│   ├── core/
│   └── infra/
│       └── build/
│           ├── development/
│           │   └── docker-compose.development.ts
│           ├── production/
│           │   └── docker-compose.production.ts
│           ├── staging/
│           │   └── docker-compose.staging.ts
│           ├── docker-compose.yml
│           └── Dockerfile
├── test/
├── .eslintrc
├── .gitignore
├── .prettierrc
├── .nestcli.json
├── package.json
├── package-lock.json
├── README.md
├── tsconfig.build.json
└── tsconfig.json

Here is the contents of my Dockerfile:

FROM node:latest

WORKDIR /app

COPY ../../../package.json ./

RUN npm install

COPY . .

EXPOSE 3000

The contents of the root docker-compose are:

version: '3.8'

services:
  api:
    build:
      context: .
    depends_on:
      - db
    ports:
      - 3000:3000
  db:
    image: mysql:latest

I run docker-compose -f src/infra/build/docker-compose.yml up from the project root dir and I get this error.

I browsed around for some similar issues but none of the solutions I found happened to work for me. I don't think I entirely understand why it fails to find the file. I'd like to. I tried different dir levels, nothing worked.

What am I doing wrong?

  • You can never `COPY ../...` anything; you can only `COPY` from the _build context directory_ and directories within it. The easiest fix is to move the Dockerfile up to the top-level directory, next to `package.json`, and adjust its paths accordingly. – David Maze Jun 27 '23 at 10:27

0 Answers0