From e2d6686bef2b58840a3fcb92657c048a0160a04b Mon Sep 17 00:00:00 2001 From: Owen Luts Date: Thu, 19 Feb 2026 14:51:36 -0500 Subject: [PATCH 1/3] added client docker containers --- .../{biweekly-pr.yaml => biweekly-pr.yml} | 0 .github/workflows/{deploy.yaml => deploy.yml} | 0 .github/workflows/node.js.yml | 32 ------------------- ...staging-deploy.yaml => staging-deploy.yml} | 0 client/.dockerignore | 2 ++ client/local.Dockerfile | 10 ++++++ client/remote.Dockerfile | 15 +++++++++ client/tailwind.config.js | 2 +- docker-compose.yml | 0 9 files changed, 28 insertions(+), 33 deletions(-) rename .github/workflows/{biweekly-pr.yaml => biweekly-pr.yml} (100%) rename .github/workflows/{deploy.yaml => deploy.yml} (100%) delete mode 100644 .github/workflows/node.js.yml rename .github/workflows/{staging-deploy.yaml => staging-deploy.yml} (100%) create mode 100644 client/.dockerignore create mode 100644 client/local.Dockerfile create mode 100644 client/remote.Dockerfile create mode 100644 docker-compose.yml diff --git a/.github/workflows/biweekly-pr.yaml b/.github/workflows/biweekly-pr.yml similarity index 100% rename from .github/workflows/biweekly-pr.yaml rename to .github/workflows/biweekly-pr.yml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yml similarity index 100% rename from .github/workflows/deploy.yaml rename to .github/workflows/deploy.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index ead019fc0..000000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - -name: Node.js CI - -on: - pull_request: - branches: ["prod", "dev"] - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x, 18.x, 20.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.current-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.current-version }} - cache: "npm" - - run: cd client - - run: npm i --legacy-peer-deps - - run: npm run build --if-present - - run: cd ../ - - run: cd server - - run: npm i --legacy-peer-deps - - run: npm run build --if-present diff --git a/.github/workflows/staging-deploy.yaml b/.github/workflows/staging-deploy.yml similarity index 100% rename from .github/workflows/staging-deploy.yaml rename to .github/workflows/staging-deploy.yml diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 000000000..b7dab5e9c --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1,2 @@ +node_modules +build \ No newline at end of file diff --git a/client/local.Dockerfile b/client/local.Dockerfile new file mode 100644 index 000000000..2ae7d9a3a --- /dev/null +++ b/client/local.Dockerfile @@ -0,0 +1,10 @@ +FROM node:20-alpine AS dependencies-env +WORKDIR /app +COPY package*.json ./ +RUN npm install --legacy-peer-deps + +FROM node:20-alpine +WORKDIR /app +COPY . . +COPY --from=dependencies-env /app/node_modules /app/node_modules +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/client/remote.Dockerfile b/client/remote.Dockerfile new file mode 100644 index 000000000..e5753711d --- /dev/null +++ b/client/remote.Dockerfile @@ -0,0 +1,15 @@ +FROM node:20-alpine AS dependencies-env +WORKDIR /app +COPY package*.json ./ +RUN npm install --legacy-peer-deps + +FROM node:20-alpine AS build-env +WORKDIR /app +COPY --from=dependencies-env /app/node_modules ./node_modules +COPY . . +RUN npm run build + +FROM node:20-alpine +WORKDIR /app +COPY --from=build-env /app/build ./build +CMD ["npx", "serve", "-s", "build", "-l", "80"] diff --git a/client/tailwind.config.js b/client/tailwind.config.js index a3886aacc..1b314a67d 100644 --- a/client/tailwind.config.js +++ b/client/tailwind.config.js @@ -2,7 +2,7 @@ const plugin = require("tailwindcss/plugin"); module.exports = { prefix: "tw-", - content: ["../client/src/**/*.{js,jsx}"], + content: ["./src/**/*.{js,jsx}"], important: true, theme: { screens: { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..e69de29bb From 9a662f7ac4e54e1b0ef2d5303bd622c29d7bdf09 Mon Sep 17 00:00:00 2001 From: Owen Luts Date: Tue, 24 Feb 2026 14:10:05 -0500 Subject: [PATCH 2/3] docker works with client,server and db --- client/local.Dockerfile | 2 +- docker-compose.yml | 35 ++++++++++++++++++++++++ server/Dockerfile | 10 +++++++ server/database/compose.yml | 4 +-- server/database/index.js | 54 ++++++++++++++++++------------------- 5 files changed, 75 insertions(+), 30 deletions(-) create mode 100644 server/Dockerfile diff --git a/client/local.Dockerfile b/client/local.Dockerfile index 2ae7d9a3a..8694f53a4 100644 --- a/client/local.Dockerfile +++ b/client/local.Dockerfile @@ -5,6 +5,6 @@ RUN npm install --legacy-peer-deps FROM node:20-alpine WORKDIR /app -COPY . . COPY --from=dependencies-env /app/node_modules /app/node_modules +COPY . ./ CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e69de29bb..33819c6aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +services: + db: + image: postgres + ports: + - '5433:5433' + restart: always + env_file: + - ./server/.env + volumes: + - ./server/database/schema.sql:/docker-entrypoint-initdb.d/schema.sql + command: -p 5433 + healthcheck: + test: ["CMD-SHELL", "pg_isready -p 5433 -U $$POSTGRES_USER -d postgres"] + interval: 5s + timeout: 5s + retries: 5 + server: + build: + context: ./server + dockerfile: Dockerfile + env_file: + - ./server/.env + ports: + - "5005:5005" + depends_on: + db: + condition: service_healthy + client: + build: + context: ./client + dockerfile: local.Dockerfile + ports: + - "3000:3000" + depends_on: + - server diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 000000000..a1284c22b --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,10 @@ +FROM node:20-alpine AS dependencies-env +WORKDIR /app +COPY package*.json ./ +RUN npm install + +FROM node:20-alpine +WORKDIR /app +COPY --from=dependencies-env /app/node_modules ./node_modules +COPY . ./ +CMD ["node", "app.js"] \ No newline at end of file diff --git a/server/database/compose.yml b/server/database/compose.yml index ecbd07703..2479ef249 100644 --- a/server/database/compose.yml +++ b/server/database/compose.yml @@ -4,10 +4,10 @@ services: db: image: postgres ports: - - "5433:5433" + - "5432:5432" restart: always env_file: - ../.env volumes: - ./schema.sql:/docker-entrypoint-initdb.d/schema.sql - command: -p 5433 + command: -p 5432 diff --git a/server/database/index.js b/server/database/index.js index cbe06a369..1722278d0 100644 --- a/server/database/index.js +++ b/server/database/index.js @@ -1,8 +1,10 @@ const fs = require('fs'); const path = require('path'); const pathname = path.join(__dirname, 'models'); -const withPassword = process.env.DB_PASS ? `:${process.env.DB_PASS}` : ''; -const URI = `postgres://${process.env.DB_USER}${withPassword}@${process.env.DB_HOST}:${process.env.ENVIRONMENT === 'dev'?5433:5432}/${process.env.DB_SCHEMA}`; +const withPassword = process.env.POSTGRES_PASSWORD + ? `:${process.env.POSTGRES_PASSWORD}` + : ''; +const URI = `postgres://${process.env.DB_USER}${withPassword}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_SCHEMA}`; const Sequelize = require('sequelize'); const sequelize = new Sequelize(URI, { dialect: 'postgres', @@ -14,34 +16,33 @@ const sequelize = new Sequelize(URI, { define: { timestamps: false, }, - logging: process.env.TESTING === 'test'? false : console.log, + logging: process.env.TESTING === 'test' ? false : console.log, }); const db = {}; sequelize - .authenticate() - .then(() => { - console.log('Connection has been established successfully.'); - }) - .catch((err) => { - console.error('Unable to connect to the database:', err); - }); + .authenticate() + .then(() => { + console.log('Connection has been established successfully.'); + }) + .catch((err) => { + console.error('Unable to connect to the database:', err); + }); const files = []; const sortDir = (maniDir) => { const folders = []; - const CheckFile = (filePath) => (fs.statSync(filePath).isFile()); + const CheckFile = (filePath) => fs.statSync(filePath).isFile(); const sortPath = (dir) => { - fs - .readdirSync(dir) - .filter((file) => (file.indexOf('.') !== 0) && (file !== 'index.js')) - .forEach((res) => { - const filePath = path.join(dir, res); - if (CheckFile(filePath)) { - files.push(filePath); - } else { - folders.push(filePath); - } - }); + fs.readdirSync(dir) + .filter((file) => file.indexOf('.') !== 0 && file !== 'index.js') + .forEach((res) => { + const filePath = path.join(dir, res); + if (CheckFile(filePath)) { + files.push(filePath); + } else { + folders.push(filePath); + } + }); }; folders.push(maniDir); let i = 0; @@ -51,11 +52,10 @@ const sortDir = (maniDir) => { } while (i < folders.length); }; sortDir(pathname); -files - .forEach((file) => { - const model = require(file)(sequelize, Sequelize.DataTypes); - db[model.name] = model; - }); +files.forEach((file) => { + const model = require(file)(sequelize, Sequelize.DataTypes); + db[model.name] = model; +}); Object.keys(db).forEach((modelName) => { if (db[modelName].associate) { From 0c6a5a09309460953470347cff7de3b525d147ba Mon Sep 17 00:00:00 2001 From: Owen Luts Date: Mon, 23 Mar 2026 10:30:34 -0400 Subject: [PATCH 3/3] removed old docker-compose --- server/database/compose.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 server/database/compose.yml diff --git a/server/database/compose.yml b/server/database/compose.yml deleted file mode 100644 index 2479ef249..000000000 --- a/server/database/compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Use postgres/example user/password credentials -version: "3.1" -services: - db: - image: postgres - ports: - - "5432:5432" - restart: always - env_file: - - ../.env - volumes: - - ./schema.sql:/docker-entrypoint-initdb.d/schema.sql - command: -p 5432