diff --git a/.github/workflows/docker-build-publish-client.yml b/.github/workflows/docker-build-publish-client.yml index 287f548..2eb930f 100644 --- a/.github/workflows/docker-build-publish-client.yml +++ b/.github/workflows/docker-build-publish-client.yml @@ -6,7 +6,7 @@ on: branches: - main paths: - - 'code/client/**' + - "code/client/**" jobs: build: @@ -24,7 +24,7 @@ jobs: uses: elgohr/Publish-Docker-Github-Action@v5 env: BUILD_DATE: ${{ env.BUILD_DATE }} - GIT_TAG: 'latest' + GIT_TAG: "latest" GIT_BRANCH: ${{ env.GIT_BRANCH }} GIT_COMMIT_SHA: ${{ env.GIT_COMMIT_SHA }} GIT_LAST_COMMIT_DATE: ${{ env.GIT_LAST_COMMIT_DATE }} @@ -32,9 +32,10 @@ jobs: name: c2dhunilu/letterbox-client username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - buildoptions: '--compress --force-rm' + buildoptions: "--compress --force-rm" buildargs: | GIT_TAG,GIT_BRANCH,GIT_COMMIT_SHA,BUILD_DATE,GIT_LAST_COMMIT_DATE - tags: 'latest' - workdir: code/ + tags: "latest" + workdir: docker/c2dhunilu + context: ../../. dockerfile: Dockerfile.client diff --git a/.github/workflows/docker-build-publish-server.yml b/.github/workflows/docker-build-publish-server.yml index ba634b5..3777f19 100644 --- a/.github/workflows/docker-build-publish-server.yml +++ b/.github/workflows/docker-build-publish-server.yml @@ -6,7 +6,7 @@ on: branches: - main paths: - - 'code/server/**' + - "code/server/**" jobs: build: @@ -24,7 +24,7 @@ jobs: uses: elgohr/Publish-Docker-Github-Action@v5 env: BUILD_DATE: ${{ env.BUILD_DATE }} - GIT_TAG: 'latest' + GIT_TAG: "latest" GIT_BRANCH: ${{ env.GIT_BRANCH }} GIT_COMMIT_SHA: ${{ env.GIT_COMMIT_SHA }} GIT_LAST_COMMIT_DATE: ${{ env.GIT_LAST_COMMIT_DATE }} @@ -32,9 +32,10 @@ jobs: name: c2dhunilu/letterbox-server username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - buildoptions: '--compress --force-rm' + buildoptions: "--compress --force-rm" buildargs: | GIT_TAG,GIT_BRANCH,GIT_COMMIT_SHA,BUILD_DATE,GIT_LAST_COMMIT_DATE - tags: 'latest' - workdir: code/ + tags: "latest" + workdir: docker/c2dhunilu + context: ../../. dockerfile: Dockerfile.server diff --git a/code/Dockerfile.client b/code/Dockerfile.client deleted file mode 100644 index 109e46d..0000000 --- a/code/Dockerfile.client +++ /dev/null @@ -1,40 +0,0 @@ -FROM node:24-alpine3.21 AS builder - -ARG BUILD_DATE -ARG GIT_TAG -ARG GIT_BRANCH -ARG GIT_COMMIT_SHA -ARG GIT_LAST_COMMIT_DATE - -# Set working directory -WORKDIR /app - -# Copy package files -COPY package.json package-lock.json ./ -COPY server/package.json ./server/ -COPY client/package.json ./client/ - -# Install dependencies at root level -RUN npm install - -# Copy source code -COPY eslint.config.mjs . -COPY client/public ./client/public -COPY client/src ./client/src -COPY client/index.html ./client/index.html -COPY client/tsconfig.app.json ./client/tsconfig.app.json -COPY client/tsconfig.json ./client/tsconfig.json -COPY client/tsconfig.node.json ./client/tsconfig.node.json -COPY client/vite.config.ts ./client/vite.config.ts -# Build the application -RUN npm run build --workspace=client - -WORKDIR /app/client/dist -# print out these env values to a info.json file -RUN echo "{\"BUILD_DATE\": \"${BUILD_DATE}\", \"GIT_TAG\": \"${GIT_TAG}\", \"GIT_BRANCH\": \"${GIT_BRANCH}\", \"GIT_COMMIT_SHA\": \"${GIT_COMMIT_SHA}\", \"GIT_LAST_COMMIT_DATE\": \"${GIT_LAST_COMMIT_DATE}\"}" > ./info.json - -WORKDIR /app/client - -FROM busybox:stable -WORKDIR /app -COPY --from=builder /app/client/dist ./ \ No newline at end of file diff --git a/code/package-lock.json b/code/package-lock.json index fd4c4e9..9317657 100644 --- a/code/package-lock.json +++ b/code/package-lock.json @@ -23,6 +23,7 @@ "@types/lodash": "4.17.16", "@types/object-hash": "^3.0.6", "concurrently": "^9.0.1", + "copyfiles": "^2.4.1", "eslint": "9.22.0", "eslint-config-prettier": "^10.0.2", "eslint-plugin-prettier": "^5.2.3", @@ -8337,6 +8338,125 @@ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", "license": "MIT" }, + "node_modules/copyfiles": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.4.1.tgz", + "integrity": "sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "glob": "^7.0.5", + "minimatch": "^3.0.3", + "mkdirp": "^1.0.4", + "noms": "0.0.0", + "through2": "^2.0.1", + "untildify": "^4.0.0", + "yargs": "^16.1.0" + }, + "bin": { + "copyfiles": "copyfiles", + "copyup": "copyfiles" + } + }, + "node_modules/copyfiles/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/copyfiles/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/copyfiles/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/copyfiles/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/copyfiles/node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/copyfiles/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/copyfiles/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, + "license": "MIT" + }, "node_modules/cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", @@ -12005,6 +12125,19 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", @@ -12346,6 +12479,44 @@ "node": ">=4" } }, + "node_modules/noms": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", + "integrity": "sha512-lNDU9VJaOPxUmXcLb+HQFeUgQQPtMI24Gt6hgfuMHRJgMRHMF/qZ4HJD3GDru4sSw9IQl2jPjAYnQrdIeLbwow==", + "dev": true, + "license": "ISC", + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "~1.0.31" + } + }, + "node_modules/noms/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/noms/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/noms/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", + "dev": true, + "license": "MIT" + }, "node_modules/normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -13117,6 +13288,13 @@ "node": ">=6.0.0" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, + "license": "MIT" + }, "node_modules/promise": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", @@ -14973,6 +15151,57 @@ "dev": true, "license": "MIT" }, + "node_modules/through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, + "node_modules/through2/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/through2/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/through2/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/through2/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/timeout-signal": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/timeout-signal/-/timeout-signal-2.0.0.tgz", @@ -15971,6 +16200,16 @@ "node": ">= 0.8" } }, + "node_modules/untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/update-browserslist-db": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", @@ -16691,6 +16930,16 @@ } } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4" + } + }, "node_modules/y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", diff --git a/code/package.json b/code/package.json index d2adf33..968fc9d 100644 --- a/code/package.json +++ b/code/package.json @@ -32,6 +32,7 @@ "@types/lodash": "4.17.16", "@types/object-hash": "^3.0.6", "concurrently": "^9.0.1", + "copyfiles": "^2.4.1", "eslint": "9.22.0", "eslint-config-prettier": "^10.0.2", "eslint-plugin-prettier": "^5.2.3", diff --git a/code/server/package.json b/code/server/package.json index dfe97ad..7aab0a1 100644 --- a/code/server/package.json +++ b/code/server/package.json @@ -4,9 +4,10 @@ "main": "build/index.js", "scripts": { "clean": "rimraf build .eslintcache", - "build": "npm run clean && npm run generate && tsc", + "build": "npm run clean && npm run generate && tsc && npm run assets", "init": "tsx src/bin/neo4j-schema", "start": "npm run init && nodemon", + "assets": "copyfiles -u 2 src/graphql/schema.graphql build/graphql/", "lint": "eslint 'src/**/*.ts' --ignore-pattern src/graphql/generated/** --cache", "test": "vitest", "generate": "graphql-codegen", diff --git a/code/server/src/index.ts b/code/server/src/index.ts index a146cee..19fd39b 100644 --- a/code/server/src/index.ts +++ b/code/server/src/index.ts @@ -20,6 +20,10 @@ async function initServer() { // Generic filter to handler errors app.use(errorFilter); + app.get('/health', (_, res) => { + res.status(200).send('Okay!'); + }); + // Create a server const server: Server = http.createServer(app); diff --git a/code/server/tsconfig.json b/code/server/tsconfig.json index f835c07..116fae2 100644 --- a/code/server/tsconfig.json +++ b/code/server/tsconfig.json @@ -5,8 +5,8 @@ "declaration": false, "declarationDir": null, "lib": ["esnext"], - "module": "Preserve", - "moduleResolution": "bundler", + "module": "NodeNext", + "moduleResolution": "NodeNext", "target": "ESNext", "outDir": "build", "rootDir": "src", diff --git a/docker/c2dhunilu/.dockerignore b/docker/c2dhunilu/.dockerignore new file mode 100644 index 0000000..0962f2c --- /dev/null +++ b/docker/c2dhunilu/.dockerignore @@ -0,0 +1,3 @@ +**/node_modules +**/build +**/dist \ No newline at end of file diff --git a/docker/c2dhunilu/Dockerfile.client b/docker/c2dhunilu/Dockerfile.client new file mode 100644 index 0000000..f78b3b4 --- /dev/null +++ b/docker/c2dhunilu/Dockerfile.client @@ -0,0 +1,36 @@ +FROM node:24-alpine3.21 AS builder + +# Set working directory +WORKDIR /app + +# Copy package files +COPY ./code/ ./ + +# Install dependencies at root level +RUN npm ci + +# Build the application +RUN npm run build --workspace=client + +WORKDIR /app/client/dist + +FROM nginx:latest + +ARG BUILD_DATE +ARG GIT_TAG +ARG GIT_BRANCH +ARG GIT_COMMIT_SHA +ARG GIT_LAST_COMMIT_DATE + +ENV DOLLAR=$ +ENV NGINX_SERVER_NAME=localhost + +COPY --from=builder /app/client/dist /var/www/client +COPY ./docker/c2dhunilu/nginx.template /etc/nginx/conf.d/nginx.template + +# Print out these env values to a info.json file +RUN echo "{\"BUILD_DATE\": \"${BUILD_DATE}\", \"GIT_TAG\": \"${GIT_TAG}\", \"GIT_BRANCH\": \"${GIT_BRANCH}\", \"GIT_COMMIT_SHA\": \"${GIT_COMMIT_SHA}\", \"GIT_LAST_COMMIT_DATE\": \"${GIT_LAST_COMMIT_DATE}\"}" > /var/www/client//info.json + +CMD ["sh", "-c", "envsubst < /etc/nginx/conf.d/nginx.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"] + +EXPOSE 80 \ No newline at end of file diff --git a/code/Dockerfile.server b/docker/c2dhunilu/Dockerfile.server similarity index 71% rename from code/Dockerfile.server rename to docker/c2dhunilu/Dockerfile.server index 8722b6d..04930a6 100644 --- a/code/Dockerfile.server +++ b/docker/c2dhunilu/Dockerfile.server @@ -1,26 +1,17 @@ -FROM node:24-alpine3.21 AS builder +FROM node:lts-alpine AS builder WORKDIR /app # Copy package files -COPY package.json package-lock.json ./ -COPY client/package.json client/ -COPY server/package.json server/ - +COPY ./code/ ./ +# Install dependencies at root level RUN npm ci -COPY prettier.config.mjs . -COPY eslint.config.mjs . -COPY tsconfig.base.json tsconfig.base.json -# Copy server source and config -COPY server/src server/src -COPY server/codegen.ts server/codegen.ts -COPY server/tsconfig.json server/tsconfig.json # Build the server application RUN npm run build --workspace=server -FROM node:24-alpine3.21 AS production +FROM node:lts-alpine AS production # Set environment to production ENV NODE_ENV=production @@ -46,6 +37,8 @@ RUN echo "{\"BUILD_DATE\": \"${BUILD_DATE}\", \"GIT_TAG\": \"${GIT_TAG}\", \"GIT # 3. Expose the default port (adjust if your Express app uses a different port) EXPOSE 3000 +WORKDIR /app/build + # 4. Command to run the application # Your server's main entry point is 'build/index.js' as defined in package.json -CMD [ "node", "build/index.js" ] \ No newline at end of file +CMD [ "node", "index.js" ] \ No newline at end of file diff --git a/code/Makefile b/docker/c2dhunilu/Makefile similarity index 94% rename from code/Makefile rename to docker/c2dhunilu/Makefile index 112062f..75482bd 100644 --- a/code/Makefile +++ b/docker/c2dhunilu/Makefile @@ -41,7 +41,7 @@ build-client: --build-arg GIT_TAG=$(TAG) \ --build-arg GIT_BRANCH=$(GIT_BRANCH) \ --build-arg GIT_COMMIT_SHA=$(GIT_COMMIT_SHA) \ - --build-arg GIT_LAST_COMMIT_DATE=$(GIT_LAST_COMMIT_DATE) . + --build-arg GIT_LAST_COMMIT_DATE=$(GIT_LAST_COMMIT_DATE) ../../. @echo "Client build successful! Image tagged as $(CLIENT_IMAGE_NAME):$(TAG)" # Target: Build the Server Image @@ -54,5 +54,5 @@ build-server: --build-arg GIT_TAG=$(TAG) \ --build-arg GIT_BRANCH=$(GIT_BRANCH) \ --build-arg GIT_COMMIT_SHA=$(GIT_COMMIT_SHA) \ - --build-arg GIT_LAST_COMMIT_DATE=$(GIT_LAST_COMMIT_DATE) . + --build-arg GIT_LAST_COMMIT_DATE=$(GIT_LAST_COMMIT_DATE) ../../. @echo "Server build successful! Image tagged as $(SERVER_IMAGE_NAME):$(TAG)" \ No newline at end of file diff --git a/docker/c2dhunilu/docker-compose.yml b/docker/c2dhunilu/docker-compose.yml new file mode 100644 index 0000000..24534dc --- /dev/null +++ b/docker/c2dhunilu/docker-compose.yml @@ -0,0 +1,78 @@ +services: + neo4j: + image: neo4j:5-community + restart: unless-stopped + user: "1000:1000" + healthcheck: + test: wget http://localhost:7474 || exit 1 + interval: 1s + timeout: 10s + retries: 20 + start_period: 20s + environment: + - NEO4J_server_memory_heap_max__size=4096m + - NEO4J_server_memory_pagecache_size=2g + - NEO4J_PLUGINS=["apoc"] + - NEO4J_AUTH=neo4j/l3tm31n! + volumes: + - ../neo4j/data/data:/data + - ../neo4j/data/logs:/logs + elasticsearch: + image: elasticsearch:8.17.3 + restart: unless-stopped + user: "1000:1000" + healthcheck: + test: curl --fail http://localhost:9200 || exit 1 + interval: 1s + timeout: 10s + retries: 20 + start_period: 20s + environment: + - TAKE_FILE_OWNERSHIP=1 + - ES_JAVA_OPTS=-Xms4g -Xmx4g + - discovery.type=single-node + - xpack.security.enabled=false + volumes: + - ../elasticsearch/data:/usr/share/elasticsearch/data + server: + image: c2dhunilu/letterbox-server:latest + restart: unless-stopped + healthcheck: + test: wget http://localhost:4000/health || exit 1 + interval: 1s + timeout: 10s + retries: 20 + start_period: 20s + depends_on: + neo4j: + condition: service_healthy + elasticsearch: + condition: service_healthy + environment: + - ELASTICSEARCH_URL=http://elasticsearch:9200 + - ELASTICSEARCH_MAX_PARALLEL_UPDATE=2 + - NEO4J_URL=bolt://neo4j:7687 + - NEO4J_LOGIN=neo4j + - NEO4J_PASSWORD=l3tm31n! + - NEO4J_DATABASE=neo4j + - DATA_FOLDER=/var/letterbox + volumes: + - ../project/data:/var/letterbox + client: + image: c2dhunilu/letterbox-client:latest + restart: unless-stopped + healthcheck: + test: curl --fail http://localhost/ || exit 1 + interval: 1s + timeout: 10s + retries: 20 + start_period: 20s + depends_on: + server: + condition: service_healthy + ports: + - 80:80 + environment: + - NGINX_UPSTREAM_SERVER=server:4000 + volumes: + - ../nginx/data/pdf:/var/www/pdf \ No newline at end of file diff --git a/docker/c2dhunilu/nginx.template b/docker/c2dhunilu/nginx.template new file mode 100644 index 0000000..b8391ab --- /dev/null +++ b/docker/c2dhunilu/nginx.template @@ -0,0 +1,42 @@ +upstream server { + server ${NGINX_UPSTREAM_SERVER}; +} + +server { + listen 80; + server_name ${NGINX_SERVER_NAME}; + client_max_body_size 50M; + root /var/www/client; + + location /graphql { + proxy_set_header X-Real-IP ${DOLLAR}remote_addr; + proxy_set_header X-Forwarded-For ${DOLLAR}proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto ${DOLLAR}http_x_forwarded_proto; + proxy_set_header Host ${DOLLAR}http_host; + proxy_set_header X-NginX-Proxy true; + proxy_set_header Cookie ${DOLLAR}http_cookie; + proxy_read_timeout 15m; + proxy_connect_timeout 15m; + proxy_pass http://server; + proxy_http_version 1.1; + proxy_set_header Upgrade ${DOLLAR}http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location ~ \.mjs$ { + types { + application/javascript mjs; + } + default_type application/javascript; + } + + location /pdf/ { + alias /var/www/pdf/; + } + + location / { + try_files ${DOLLAR}uri ${DOLLAR}uri/ /index.html; + } + + +}