moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 119 forks source link

docker-compose fails to spin up service containers #270

Closed rishighan closed 2 years ago

rishighan commented 2 years ago

Hello, I have the following services:

https://github.com/rishighan/threetwo-import-service/tree/master/services

Here's the Dockerfile for this project:

FROM node:buster-slim

# Show all node logs
ENV NPM_CONFIG_LOGLEVEL warn
ENV NODE_ENV=production

WORKDIR /threetwo-import-service

RUN apt-get update \
    && apt-get upgrade -y \
    && apt-get install -y \
    bash git openssh-server \
    ca-certificates \
    gcc \
    libgl1-mesa-glx \
    python3 python3-pip \
    qtbase5-dev \
    wget \
    xdg-utils \
    xz-utils \
    libvips-dev build-essential

RUN wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sh /dev/stdin install_dir=/opt isolated=y && \
    rm -rf /tmp/calibre-installer-cache

COPY package.json package-lock.json ./
COPY moleculer.config.ts ./
COPY tsconfig.json ./

# Install Dependncies
RUN npm install -g typescript ts-node
RUN npm ci --silent

COPY . .

# Build and cleanup
RUN npm run build \
 && npm prune

EXPOSE 3000
# Start server
CMD ["npm", "start"]

I have a docker-compose configuration that looks like this:

version: "3.7"

services:
  nginx:
    image: nginx
    container_name: proxy
    ports:
      - "80:80"
    volumes:
      - ./proxy.conf:/etc/nginx/conf.d/default.conf 

  threetwo:
    build:
      context: .
    image: frishi/threetwo
    container_name: threetwo-ui
    ports:
      - "8050:8050"
      - "3050:3050"
    networks:
      - proxy

  //....

  importapi:
    build:
      context: https://github.com/rishighan/threetwo-import-service.git
    image: frishi/threetwo-import-service
    container_name: threetwo-import-api
    ports:
      - "3000:3000"
    environment:
      SERVICES: api
    env_file: threetwo-import-service.env
    depends_on:
      - nats
      - mongodb
    networks:
      - proxy

  import:
    build:
      context: https://github.com/rishighan/threetwo-import-service.git
    image: frishi/threetwo-import-service
    container_name: import
    depends_on: 
      - mongodb
    environment:
      SERVICES: import 
    env_file: threetwo-import-service.env
    networks:
      - proxy

  imagetransformation:
    build:
      context: https://github.com/rishighan/threetwo-import-service.git
    image: frishi/threetwo-import-service
    container_name: image-transformation
    depends_on: 
      - mongodb 
    environment:
      SERVICES: imagetransformation 
    env_file: threetwo-import-service.env
    networks:
      - proxy

  mongodb:
    image: 'bitnami/mongodb:latest'
    container_name: mongodb
    networks:
      - proxy
    ports:
      - "27017:27017"
    volumes:
      - 'mongodb_data:/bitnami/mongodb'

  nats:
    image: nats:2
    container_name: transporter
    networks:
      - proxy

networks:
  proxy:
    external: true

volumes:
  mongodb_data:
    driver: local

import, imagetransformation and the api gateway for these services fail with the following error:

import                 | [Runner] Config file not found: /threetwo-import-service/dist/moleculer.config.js Error: Config file not found: /threetwo-import-service/dist/moleculer.config.js
import                 |     at MoleculerRunner.loadConfigFile (/threetwo-import-service/node_modules/moleculer/src/runner.js:161:27)
import                 |     at /threetwo-import-service/node_modules/moleculer/src/runner.js:477:21
image-transformation   | [Runner] Config file not found: /threetwo-import-service/dist/moleculer.config.js Error: Config file not found: /threetwo-import-service/dist/moleculer.config.js
image-transformation   |     at MoleculerRunner.loadConfigFile (/threetwo-import-service/node_modules/moleculer/src/runner.js:161:27)
image-transformation   |     at /threetwo-import-service/node_modules/moleculer/src/runner.js:477:21
threetwo-import-api    | [Runner] Config file not found: /threetwo-import-service/dist/moleculer.config.js Error: Config file not found: /threetwo-import-service/dist/moleculer.config.js
threetwo-import-api    |     at MoleculerRunner.loadConfigFile (/threetwo-import-service/node_modules/moleculer/src/runner.js:161:27)
threetwo-import-api    |     at /threetwo-import-service/node_modules/moleculer/src/runner.js:477:21
import exited with code 1
image-transformation exited with code 1

When I docker build and docker run just the threetwo-import-service it runs just fine. Is it something to do with the build context? Kind of stuck here...

0x0a0d commented 2 years ago

Config file not found: /threetwo-import-service/dist/moleculer.config.js

WORKDIR /threetwo-import-service

COPY package.json package-lock.json ./
# file will be placed at /threetwo-import-service/moleculer.config.ts
# should be
# COPY moleculer.config.ts ./dist
COPY moleculer.config.ts ./

COPY tsconfig.json ./