Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

463
Views
TypeScript compilation failing inside Dockerfile

I have the following Dockerfile which is failing at the step which compiles TypeScript:

FROM node:12
WORKDIR /usr/src/app

# SETUP

COPY package.json .
COPY tsconfig.json .
COPY src .

RUN npm install -g yarn@^1.16.0
RUN yarn install

# BUILD

RUN npx tsc <------------------------

The error message is very confusing:

File '/usr/src/app/app.ts' is not under 'rootDir' '/usr/src/app/src'. 'rootDir' is expected to contain all source files.

This makes no sense... It's finding app.ts under the src folder and then complaining that it isn't under the src folder.

Files:

src
  app.ts
tsconfig.json
Dockerfile

How do I solve this issue?

Here is my tsconfig.json:

{
  "compilerOptions": {
    ...
    "rootDir": "./src",
    "outDir": "./build",
    ...
  }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Wow, it was such a simple problem unrelated to TypeScript.

I didn't do the COPY command correctly.

When copying files you can do COPY <filename> .

But apparently for directories you must do COPY <dirname> <dirname>

So I fixed this by changing COPY src . to COPY src src.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!