Using docker, I successfully built my project by running yarn tsc
. However, when I executed docker run -p88:5011 accounts2
I encountered the following error:
PM2 error: Error: Script not found: /home/accounts/dist/server/index.js
. This error occurs despite following the manual process.
Below is my docker file:
FROM node:10.16-alpine
# Install PM2
RUN npm install pm2 -g
# Add bash support to image
RUN apk add --no-cache bash
# Create service directory
RUN mkdir -p /home/accounts
WORKDIR /home/accounts
# Copy working files
COPY package.json /home/accounts
COPY . /home/accounts
# Install dependencies
RUN yarn install
RUN yarn tsc
EXPOSE 5011
# Start command
CMD [ "pm2-runtime", "process.yml" ]
Contents of my process.yml:
apps:
- script: ./dist/server/index.js
name: accounts
instances: maad
exec_mode: cluster
watch: false
autorestart: true
out_file: /dev/null
ignore_watch:
- logs
- node_modules
- worker\.js
- \.git/index\.lock
- \.log
- \.lock
watch_options:
followSymlinks: false
Directory Structure:
home/
.circleci/
config.yml
src/
dist/
server/
index.js
process.yml