Here is my Dockerfile :
# Download the slim version of node
FROM node:21-slim
# Set the work directory to app folder.
# We will be copying our code here
WORKDIR /src
#Copy package.json file in the node folder inside container
COPY package.json .
# Copy the rest of the code in the container
COPY . .
# Install the dependencies in the container
RUN npm install
# Run the node server with server.js file
CMD ["npm", "start"]
# Expose the service over PORT 5000
EXPOSE 5000
Here is my package.json starting command :
"scripts": {
"start": "nodemon -w src --ext ts --exec ts-node --esm src/app.ts"
},
Here is my docker-compose.yml :
version: '3.8'
services:
node_app:
build: ./node
container_name: node
environment:
- NODE_ENV=development
- PORT=5000
command: sh -c "npm start"
volumes:
- ./node:/home/node/app:cached
ports:
- '5000:5000'
And here is my file structure in vscode : file structure
And when I'm running docker inside this project with docker-compose build && docker-compose up -d, I'm getting the TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /src/src/app.ts error.
I'm sure I'm missing something around docker and app paths but I didn't managed to find what.