I am creating an API. I have the node code locally and the MySQL container from docker. I have tried setting up Docker Compose with the two services but, while MySQL runs just fine, the node app doesn’t work.
I have researched the issue and tried changing my Dockerfile on the node app, deleting my package-json file and running docker compose up -d --build but it still displays this message when running docker compose up
node_app | /bin/sh: 1: [node,: not found
The node app is using sequelize to connect to the DB.
Here is my Dockerfile
FROM node:20
COPY package.json /app/
COPY src /app/
COPY dist /app/
WORKDIR /app
RUN npm install
EXPOSE 3000
CMD ["node", "./dist/index.js"];
My docker-compose.yml
services:
node_app:
container_name: node_app
build: .
working_dir: /app/dist
ports:
- "9000:3000"
environment:
- MYSQL_DB=shopper-test-db
- MYSQL_USER=emerson
- MYSQL_PASSWORD=root
- MYSQL_HOST=node_db
restart: always
depends_on:
- node_db
node_db:
container_name: node_db
image: mysql
ports:
- "3306:3306"
environment:
- MYSQL_DATABASE=shopper-test-db
- MYSQL_ROOT_PASSWORD=root
I am using typescript with node, so the src folder is where the TS files are stores and dist stores the JS conversions