Héctor
Héctor

Reputation: 26034

Docker build working in my machine but not in Gitlab CI

I have a Dockerized Typescript NodeJS aplication and I want to build Docker image from Gitlab CI.

Dockerfile

FROM node:11.13.0-alpine

WORKDIR /usr/src/app/

COPY . .
RUN npm install
RUN npm run build

CMD ["node", "dist/main.js"]

.gitlab-ci.yml

image: ubuntu:bionic

stages:
  - deploy

before_script:
  # OS dependencies
  - apt-get update
  - apt-get install -y gnupg2
  - apt-get install -y software-properties-common

  # Install docker
  - apt install -y docker.io
  - service docker start

  # Install cURL
  - apt-get install -y curl

deploy:
  stage: deploy
  script:
    - docker build -t my_app .
    # more stuff

If I run docker build -t my_app . in my local Mac OS, everything works fine. But in Gitlab CI (Ubuntu), it throws these errors in step RUN npm run build:

src/contact/contact.mapper.ts(1,25): error TS2307: Cannot find module './contact'.
src/contact/contact.repository.ts(2,25): error TS2307: Cannot find module './contact'.
src/contact/contact.resolver.ts(3,25): error TS2307: Cannot find module './contact'.
...

Docker versions are the same in Gitlab CI and my local. Do I need something else to make it work in Ubuntu (Gitlab CI runner image)?

NOTE: I know Docker in Docker can be used in Gitlab CI, but for some reasons I need to install Docker manually.

Edit

Also, if I run npm run build in my local (using Node v11.13.0, same version as Dockerfile), it works, too.

EDIT

I have just run docker built -t my_app . in an Ubuntu machine (using a Vagrant virtual machine) and it doesn't work. So, definitely this errors is about operating system. It works in Mac OS but not in Ubuntu.

Upvotes: 1

Views: 1238

Answers (1)

Héctor
Héctor

Reputation: 26034

Finally, I found the error. File was actually named Contact.ts and not contact.ts. It seems that in Mac OS, unlike Ubuntu, paths are case insensitive.

Upvotes: 2

Related Questions