Hi,
I am starting to learn docker and want to learn docker by dockerizing my existing app (for practice). But I am running into this error Operation timed out exited with code 0 on the api in the docker-compose file.
It should run all the code in the backend/ dir but for some reason, it is creating a sub-director backend/backend/node_modules where node_modules and the nested backend are empty. The app running cmd in the main backend dir.
Am I doing something wrong here?
# Stage 1: Install Dependencies (Cacheable)
FROM node:18-alpine AS builder
WORKDIR /app
RUN apk add --no-cache curl
COPY package*.json ./
RUN npm install --legacy-peer-deps
# Stage 2: Copy Application Code (Production)
FROM node:18-alpine
WORKDIR /backend
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json .
COPY start.sh .
COPY wait-for.sh .
COPY . .
EXPOSE 3001
CMD [ "npm", "run", "start:dev" ]
version: "3.9"
services:
redis:
container_name: tgc_sc_redis
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli","ping"]
interval: 5s
retries: 3
ports:
- "6379:6379"
networks:
- tgc_sc_network
rabbitmq:
container_name: tgc_sc_rabbitmq
image: rabbitmq:3-management-alpine
ports:
- "5673:5673"
- "15673:15673"
volumes:
- ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/
- ~/.docker-conf/rabbitmq/log/:/var/log/rabbitmq/
networks:
- tgc_sc_network
api:
restart: on-failure
build:
context: ./backend
dockerfile: Dockerfile
container_name: tgc_sc_api
volumes:
- ./backend:/backend
- ./backend/node_modules:/backend/node_modules/
ports:
- "3001:3001"
networks:
- tgc_sc_network
depends_on:
- redis
- rabbitmq
entrypoint: ["/backend/wait-for.sh", "rabbitmq:5673", "--" , "/backend/start.sh"]
command: [ "npm", "run", "start:dev" ]
volumes:
node_modules:
backend:
networks:
tgc_sc_network:
name: tgc_sc_network
driver: bridge