Skip to content

Commit

Permalink
install pm2 globally and source ecosystem.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tagyoureit committed Jun 9, 2024
1 parent 3c145ab commit 0acfdbd
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 11 deletions.
36 changes: 25 additions & 11 deletions .docker/Dockerfile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ WORKDIR /app/nodejs-poolcontroller
# Copy the source code and necessary files for the first application
COPY ./nodejs-poolcontroller/defaultConfig.json ./config.json
COPY ./nodejs-poolcontroller ./
RUN echo "pwd"
RUN echo "current pwd - $(pwd)"
RUN echo "ls"
RUN echo "$(ls -al)"
COPY ./nodejs-poolcontroller/.docker/ecosystem.config.js ./ecosystem.config.js

# Install dependencies and build the first application
RUN npm ci
RUN npm run build

# Install PM2 globally
RUN npm install pm2 -g

# Second stage for the second application
FROM node:lts-alpine AS build-njspc-dp

Expand All @@ -41,12 +35,28 @@ COPY ./nodejs-poolcontroller-dashpanel ./
RUN npm ci
RUN npm run build

# Install PM2 globally
RUN npm install pm2 -g
# Third stage for relayEquipmentManager
# FROM node:lts-alpine AS build-rem

# Create the app directory and set ownership for relayEquipmentManager
# RUN mkdir -p /app/relayEquipmentManager && chown node:node /app/relayEquipmentManager

# Set the working directory for relayEquipmentManager
# WORKDIR /app/relayEquipmentManager

# Third stage for the final combined image
# Copy the source code and necessary files for relayEquipmentManager
# COPY ./relayEquipmentManager ./

# Install dependencies and build relayEquipmentManager
# RUN npm ci
# RUN npm run build

# Fourth stage for the final combined image
FROM node:lts-alpine AS final

# Install PM2 globally
RUN npm install pm2 -g

# Create the app directory and set ownership
RUN mkdir -p /app && chown node:node /app

Expand All @@ -56,9 +66,13 @@ WORKDIR /app
# Copy built applications from the previous stages into the final image
COPY --from=build-njspc /app/nodejs-poolcontroller ./nodejs-poolcontroller
COPY --from=build-njspc-dp /app/nodejs-poolcontroller-dashpanel ./nodejs-poolcontroller-dashpanel
# COPY --from=build-rem /app/relayEquipmentManager ./relayEquipmentManager

# Copy the ecosystem configuration file from the build stage
COPY --from=build-njspc /app/nodejs-poolcontroller/ecosystem.config.js ./ecosystem.config.js

# Expose any necessary ports
EXPOSE 4200 5150

# Define the command to run both applications using PM2
CMD ["pm2-runtime", "start", "/app/nodejs-poolcontroller-dashpanel/ecosystem.config.js", "--", "start", "/app/nodejs-poolcontroller/ecosystem.config.js"]
CMD ["pm2-runtime", "start", "ecosystem.config.js
35 changes: 35 additions & 0 deletions .docker/ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
apps: [
{
name: "dashPanel",
script: "npm",
args: ["start"],
cwd: "/app/nodejs-poolcontroller-dashpanel",
restart_delay: 10000,
watch: [
"pages",
"scripts",
"server",
"package.json"
],
watch_delay: 5000,
kill_timeout: 15000
},
{
name: "njsPC",
script: "npm",
args: ["start"],
cwd: "/app/nodejs-poolcontroller",
restart_delay: 10000,
watch: [
"config",
"controller",
"logger",
"web",
"package.json"
],
watch_delay: 5000,
kill_timeout: 15000
}
]
};
64 changes: 64 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = {
apps : [
{
"name": "REM",
"script": "npm",
"args": [
"start"
],
"cwd": "/home/pi/relayEquipmentManager",
"restart_delay": 10000,
"watch": [
"boards",
"config",
"connections",
"devices",
"gpio",
"i2c-bus",
"logger",
"pages",
"pinouts",
"spi-adc",
"web",
"package.json"
],
"watch_delay": 5000,
"kill_timeout": 15000
},
{
"name": "dashPanel",
"script": "npm",
"args": [
"start"
],
"cwd": "/home/pi/nodejs-poolController-dashPanel",
"restart_delay": 10000,
"watch": [
"pages",
"scripts",
"server",
"package.json"
],
"watch_delay": 5000,
"kill_timeout": 15000
},
{
"name": "njsPC",
"script": "npm",
"args": [
"start"
],
"cwd": "/home/pi/nodejs-poolController",
"restart_delay": 10000,
"watch": [
"config",
"controller",
"logger",
"web",
"package.json"
],
"watch_delay": 5000,
"kill_timeout": 15000
}
]
};

0 comments on commit 0acfdbd

Please sign in to comment.