Skip to content

Commit

Permalink
Merge pull request #1 from tagyoureit/master
Browse files Browse the repository at this point in the history
Update to most recent code-base
  • Loading branch information
treyrich authored Jul 15, 2024
2 parents 519506a + 0267217 commit d3bb56c
Show file tree
Hide file tree
Showing 38 changed files with 4,588 additions and 3,510 deletions.
29 changes: 29 additions & 0 deletions .docker/Dockerfile.armv6
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use a base image compatible with ARMv6 architecture
FROM arm32v6/node:14-alpine

# Install necessary build dependencies
RUN apk add --no-cache make gcc g++ python3 linux-headers udev tzdata git

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies (both development and production)
RUN npm ci

# Copy the rest of the application
COPY . .

# Build the application
RUN npm run build

# Set environment variables
ENV NODE_ENV=production

# Expose the port (if applicable)
EXPOSE 4200

# Command to run the application
CMD ["node", "dist/app.js"]
29 changes: 29 additions & 0 deletions .docker/Dockerfile.armv7
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use a base image compatible with ARMv7 architecture
FROM arm32v7/node:14-alpine

# Install necessary build dependencies
RUN apk add --no-cache make gcc g++ python3 linux-headers udev tzdata git

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies (both development and production)
RUN npm ci

# Copy the rest of the application
COPY . .

# Build the application
RUN npm run build

# Set environment variables
ENV NODE_ENV=production

# Expose the port (if applicable)
EXPOSE 4200

# Command to run the application
CMD ["node", "dist/app.js"]
62 changes: 62 additions & 0 deletions .docker/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Use a Linux-based image as the build stage for the first application
FROM node:lts-alpine AS build-njspc

# Install necessary build dependencies
RUN apk add --no-cache make gcc g++ python3 linux-headers udev tzdata

# Create the app directory and set ownership for the first application
RUN mkdir -p /app/nodejs-poolcontroller && chown node:node /app/nodejs-poolcontroller

# Set the working directory for the first application
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 ./
COPY ./.docker/ecosystem.config.js ./ecosystem.config.js

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

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

# Create the app directory and set ownership for the second application
RUN mkdir -p /app/nodejs-poolcontroller-dashpanel && chown node:node /app/nodejs-poolcontroller-dashpanel

# Set the working directory for the second application
WORKDIR /app/nodejs-poolcontroller-dashpanel

# Copy the source code and necessary files for the second application
COPY ./nodejs-poolcontroller-dashpanel ./

# Install dependencies and build the second application
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

# Set the working directory for the final combined image
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", "ecosystem.config.js"]
43 changes: 43 additions & 0 deletions .docker/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use a Windows-based image as the build stage
FROM mcr.microsoft.com/windows/servercore:ltsc2019 AS build

# Set the working directory
WORKDIR C:\app

# Copy package.json and package-lock.json files
COPY package*.json ./
COPY defaultConfig.json config.json

# Install Node.js
RUN curl -sL https://nodejs.org/dist/v14.17.6/node-v14.17.6-x64.msi -o node.msi
RUN msiexec /i node.msi /quiet

# Install npm dependencies
RUN npm ci

# Copy the rest of the application files
COPY . .

# Build the application
RUN npm run build

# Second stage for the production image
FROM mcr.microsoft.com/windows/servercore:ltsc2019 as prod

# Install git
RUN powershell -Command "Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/Git-2.33.1-64-bit.exe -OutFile git.exe" && .\git.exe /VERYSILENT /NORESTART

# Create the app directory
RUN mkdir C:\app

# Set the working directory
WORKDIR C:\app

# Copy built application from the build stage
COPY --from=build C:\app .

# Set environment variables
ENV NODE_ENV=production

# Define the entrypoint
CMD ["node", "dist/app.js"]
47 changes: 47 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '3.8'

services:
poolcontroller:
image: tagyoureit/nodejs-poolcontroller:latest
container_name: poolcontroller
restart: always
group_add:
- dialout
devices:
- /dev/ttyUSB0
ports:
- "4200:4200"
volumes:
- /data/poolcontroller/config.json:/app/nodejs-poolcontroller/config.json
- /data/poolcontroller/data:/app/nodejs-poolcontroller/data
- /data/poolcontroller/logs:/app/nodejs-poolcontroller/logs
poolcontroller-dashpanel:
restart: always
container_name: poolcontroller-dashpanel
ports:
- "5150:5150"
volumes:
- /data/poolcontroller-dashpanel/config.json:/app/nodejs-poolcontroller-dashpanel/config.json
image: rstrouse/nodejs-poolcontroller-dashpanel:latest
depends_on:
- poolcontroller

# poolcontroller-armv7:
# image: tagyoureit/nodejs-poolcontroller-armv7:latest
# container_name: poolcontroller-armv7
# restart: always
# ports:
# - "4200:4200"
# volumes:
# - /data/poolcontroller/config.json:/app/config.json
# - /data/poolcontroller/data:/app/data

# poolcontroller-armv6:
# image: tagyoureit/nodejs-poolcontroller-armv6:latest
# container_name: poolcontroller-armv6
# restart: always
# ports:
# - "4200:4200"
# volumes:
# - /data/poolcontroller/config.json:/app/config.json
# - /data/poolcontroller/data:/app/data
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
}
]
};
81 changes: 81 additions & 0 deletions .github/workflows/docker-publish-njsPC-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Publish Docker Image - Ubuntu

on:
push:
branches:
- master
- docker
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Checkout code from tagyoureit/nodejs-poolcontroller
uses: actions/checkout@v3
with:
repository: tagyoureit/nodejs-poolcontroller
ref: master # or specify the branch or tag to pull from
path: nodejs-poolcontroller

- name: Checkout code from rstrouse/nodejs-poolcontroller-dashpanel
uses: actions/checkout@v3
with:
repository: rstrouse/nodejs-poolcontroller-dashpanel #
ref: master # Specify the branch or tag to pull from
path: nodejs-poolcontroller-dashpanel # Specify the directory to checkout the code into

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push combined Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./.docker/Dockerfile.linux
push: true
tags: |
tagyoureit/njspc-dp-combined-app:latest

# - name: Build and push njsPC Linux Docker image (x86_64)
# uses: docker/build-push-action@v4
# with:
# context: .
# file: ./.docker/Dockerfile.linux
# push: true
# tags: |
# tagyoureit/nodejs-poolcontroller:latest

# - name: Build and push njsPC-dP Linux Docker image (x86_64)
# uses: docker/build-push-action@v4
# with:
# context: nodejs-poolcontroller-dashpanel
# file: ./.docker/Dockerfile.linux
# push: true
# tags: |
# rstrouse/nodejs-poolcontroller-dashpanel:latest

# - name: Build and push ARMv7 Docker image
# uses: docker/build-push-action@v4
# with:
# context: .
# file: ./.docker/Dockerfile.armv7 # Adjust the path to your ARMv7 Dockerfile
# push: true
# tags: |
# tagyoureit/nodejs-poolcontroller-armv7:latest

# - name: Build and push ARMv6 Docker image
# uses: docker/build-push-action@v4
# with:
# context: .
# file: ./.docker/Dockerfile.armv6 # Adjust the path to your ARMv6 Dockerfile
# push: true
# tags: |
# tagyoureit/nodejs-poolcontroller-armv6:latest
41 changes: 41 additions & 0 deletions .github/workflows/docker-publish-njsPC-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Docker Image - Windows

on:
push:
branches:
- docker
workflow_dispatch:


jobs:
build-and-push-windows:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Windows Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.windows
push: true
tags: |
tagyoureit/nodejs-poolcontroller:windows-latest
platforms: windows/amd64
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```diff
- INTELLICENTER USERS: Do not upgrade to 2.006. Rollback to 1.064 to use this application.
- INTELLICENTER USERS: Do not upgrade Intellicenter to 2.006. Rollback to 1.064 to use this application.
```
# nodejs-poolController - Version 8.0

Expand Down Expand Up @@ -52,7 +52,7 @@ This is only the server code. See [clients](#module_nodejs-poolController--clie
### Prerequisites
If you don't know anything about NodeJS, these directions might be helpful.

1. Install Nodejs (v12 recommended). (https://nodejs.org/en/download/)
1. Install Nodejs (v16+ required). (https://nodejs.org/en/download/)
1. Update NPM (https://docs.npmjs.com/getting-started/installing-node).
1. It is recommended to clone the source code as updates are frequently pushed while releases are infrequent
clone with `git clone https://github.com/tagyoureit/nodejs-poolController.git`
Expand Down
Loading

0 comments on commit d3bb56c

Please sign in to comment.