As a newcomer to Docker, I am attempting to configure my fullstack API REST project. Within my PNPM workspace, I have two applications - a frontend built with Angular and a backend developed using AdonisJS. My goal is to create a Docker configuration for Phpmyadmin, Mysql, Angular, and Adonis, but I have encountered the following issue:
Here is the structure of my project:
APPS /
- BACKEND
- DOCKERFILE
- FRONT END
- docker-compose
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ts-node' imported from /app/apps/backend/ace.js
This is my docker-compose file:
version: '3.8'
services:
mysql:
image: mysql:latest
volumes:
- mysql_data:/var/lib/mysql
ports:
- '3306:3306'
networks:
- default
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: password
phpmyadmin:
container_name: phpmyadmin
image: phpmyadmin/phpmyadmin:latest
restart: always
networks:
- default
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: root
ports:
- "8080:80"
depends_on:
- mysql
adonisjs:
build: ./apps/backend
working_dir: /app
volumes:
- .:/app
ports:
- "3333:3333"
depends_on:
- mysql
environment:
- APP_KEY=xxxxx
- DB_CONNECTION=mysql
- DB_HOST=mysql
- DB_PORT=3306
- DB_USER=user
- DB_PASSWORD=password
- DB_DATABASE=database
networks:
default:
driver: bridge
volumes:
mysql_data:
And this is my Dockerfile:
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
COPY wait-for-it.sh /usr/wait-for-it.sh
RUN chmod +x /usr/wait-for-it.sh
RUN pnpm add ts-node -D
CMD /usr/wait-for-it.sh mysql:3306 -- pnpm dev:all
EXPOSE 3333
Thank you for your assistance :)