I have a couple docker containers working together, when i run compose locally it works, and when i run docker run on the express dockerfile it works.
I am trying to deploy this to a cloud host so i follow these steps: 1- save code. 2- build images 3- push images to hub 4- run docker-compose in server through ssh
i see the client and the database containers working but the express exits with
express_server | npm ERR! code ENOENT
express_server | npm ERR! syscall open
express_server | npm ERR! path /src/package.json
express_server | npm ERR! errno -2
express_server | npm ERR! enoent ENOENT: no such file or directory, open '/src/package.json'
express_server | npm ERR! enoent This is related to npm not being able to find a file.
express_server | npm ERR! enoent
express_server |
express_server | npm ERR! A complete log of this run can be found in:
express_server | npm ERR! /home/node/.npm/_logs/2021-09-20T22_29_26_142Z-debug.log
while i understand its an issue with the src file not containing the package.json i cant figure out why its not there in the image or what i should do differently for the compose file which is
docker-compose(partial)
express:
container_name: express_server
networks:
- client
- server
# The location of dockerfile to build this service
image: "bork/server:latest"
# Command to run once the Dockerfile completes building
command: npm run start
# Volumes, mounting our files to parts of the container
volumes:
- .:/src/app
# Ports to map, mapping our port 3000, to the port 3000 on the container
ports:
- 3000:3000
# designating a file with environment variables
env_file:
- config/.env.express
local dockerfile
# syntax=docker/dockerfile:1
FROM node:14.17.5
ENV NODE_ENV=production
#RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /src
COPY package*.json /src/
#USER node
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "run", "startdev"]
can anyone spot the problem?