1

I have a docker setup with AdonisJS 5. I'm currently trying to get it started (and it builds just fine). But as discussed a bit further down, the ace command cannot be found. ace is the CLI package for AdonisJS (think ng for Angular)

This is my Dockerfile:

ARG NODE_IMAGE=node:16.13.1-alpine

FROM $NODE_IMAGE AS base
RUN apk --no-cache add dumb-init
RUN mkdir -p /home/node/app && chown node:node /home/node/app
WORKDIR /home/node/app
USER node
RUN mkdir tmp

FROM base AS dependencies
COPY --chown=node:node ./package*.json ./
RUN npm ci
RUN npm i @adonisjs/cli
COPY --chown=node:node . .

FROM dependencies AS build
RUN node ace build --production

FROM base AS production
ENV NODE_ENV=production
ENV PORT=$PORT
ENV HOST=0.0.0.0
COPY --chown=node:node ./package*.json ./
RUN npm ci --production
COPY --chown=node:node --from=build /home/node/app/build .
EXPOSE $PORT
CMD [ "dumb-init", "node", "service/build/server.js" ]

And this is my docker-compose.yml:

version: '3.9'

services:
 postgres:
   container_name: postgres
   image: postgres
   restart: always
   environment:
     - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
     - POSTGRES_USER=${POSTGRES_USER:-user}
   networks:
     - family-service-network
   volumes:
     - fn-db_volume:/var/lib/postgresql/data

 adminer:
   container_name: adminer
   image: adminer
   restart: always
   networks:
     - family-service-network
   ports:
     - 8080:8080

 minio:
   container_name: storage
   image: 'bitnami/minio:latest'
   ports:
     - '9000:9000'
     - '9001:9001'
   environment:
     - MINIO_ROOT_USER=user
     - MINIO_ROOT_PASSWORD=password
     - MINIO_SERVER_ACCESS_KEY=access-key
     - MINIO_SERVER_SECRET_KEY=secret-key
   networks:
     - family-service-network
   volumes:
     - fn-s3_volume:/var/lib/postgresql/data

 fn_service:
   container_name: fn_service
   restart: always
   build:
     context: ./service
     target: dependencies
   ports:
     - ${PORT:-3333}:${PORT:-3333}
     - 9229:9229
   networks:
     - family-service-network
   env_file:
     - ./service/.env
   volumes:
     - ./:/home/node/app
     - /home/node/app/node_modules
   depends_on:
     - postgres
   command: dumb-init node ace serve --watch --node-args="--inspect=0.0.0.0"

volumes:
 fn-db_volume:
 fn-s3_volume:

networks:
 family-service-network:

When I run this with docker-compose up everything works, except for the fn_service. I get the error:

Error: Cannot find module '/home/node/app/ace'

    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)

    at Function.Module._load (node:internal/modules/cjs/loader:778:27)

    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)

    at node:internal/main/run_main_module:17:47 {

  code: 'MODULE_NOT_FOUND',

  requireStack: []

}

node:internal/modules/cjs/loader:936

  throw err;

  ^

I followed this tutorial, and I can't seem to find anything by googling. I'm sure it's something miniscule.

Any help would be appreciated.

Daechir
  • 79
  • 10

0 Answers0