From 943620c8a28bbb57fb02efb591e455780753730f Mon Sep 17 00:00:00 2001 From: Satyam Bajpai Date: Wed, 4 Sep 2024 10:32:15 +0530 Subject: [PATCH 1/2] draft: write initial docker file --- .dockerignore | 2 ++ Dockerfile | 27 ++++++++++++++++++++ app/constants/urls.js | 12 ++++++--- fastboot-server.js | 5 +++- package.json | 4 +-- yarn.lock | 57 ++++++++++++++++++++++++++----------------- 6 files changed, 78 insertions(+), 29 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..de625bebe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..aa78c225d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Utilize the Node.js 14 official image +FROM node:18-alpine + +USER root + +# Set the working directory inside the container +WORKDIR /app + +# Copy the package.json and package-lock.json (if available) +# COPY package*.json ./ + +# Install the dependencies + + +# Copy the rest of the application code +COPY . . + +RUN yarn install --frozen-lockfile + +# Build the Fastboot app +RUN yarn build + +# Expose the port the Fastboot app runs on +EXPOSE 5000 + +# Define the command to run your Fastboot app +CMD ["node", "fastboot-server"] diff --git a/app/constants/urls.js b/app/constants/urls.js index b65938f26..8609d7a71 100644 --- a/app/constants/urls.js +++ b/app/constants/urls.js @@ -14,7 +14,10 @@ const APP_URLS = { TASKS: `${SCHEME}my.${DOMAIN}/tasks`, IDENTITY: `${SCHEME}my.${DOMAIN}/identity`, MY_STATUS: `${SCHEME}my.${DOMAIN}`, - API_BACKEND: `${SCHEME}api.${DOMAIN}`, + // API_BACKEND: `${SCHEME}api.${DOMAIN}`,hostWhitelist + + API_BACKEND: `http://localhost:3000`, + DASHBOARD: `${SCHEME}dashboard.${DOMAIN}`, }, staging: { @@ -27,8 +30,8 @@ const APP_URLS = { TASKS: `${SCHEME}staging-my.${DOMAIN}/tasks`, IDENTITY: `${SCHEME}staging-my.${DOMAIN}/identity`, MY_STATUS: `${SCHEME}staging-my.${DOMAIN}`, - API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, - DASHBOARD: `${SCHEME}staging-dashboard.${DOMAIN}`, + // API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, + API_BACKEND: `http://localhost:3000`, }, development: { HOME: `${SCHEME}staging-www.${DOMAIN}`, @@ -41,7 +44,8 @@ const APP_URLS = { IDENTITY: `${SCHEME}staging-my.${DOMAIN}/identity`, MY_STATUS: `${SCHEME}staging-my.${DOMAIN}`, DASHBOARD: `${SCHEME}staging-dashboard.${DOMAIN}`, - API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, + // API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, + API_BACKEND: `http://localhost:3000`, }, test: { HOME: `${SCHEME}${DOMAIN}`, diff --git a/fastboot-server.js b/fastboot-server.js index b0b8fe3ce..4d75de450 100644 --- a/fastboot-server.js +++ b/fastboot-server.js @@ -1,5 +1,7 @@ -import FastBootAppServer from 'fastboot-app-server'; +// import FastBootAppServer from 'fastboot-app-server'; +// eslint-disable-next-line no-undef +const FastBootAppServer = require('fastboot-app-server'); const MY_GLOBAL = 'MY GLOBAL'; let server = new FastBootAppServer({ @@ -9,6 +11,7 @@ let server = new FastBootAppServer({ // Optional - Make values available to the Ember app running in the FastBoot server, e.g. "MY_GLOBAL" will be available as "GLOBAL_VALUE" return Object.assign({}, defaultGlobals, { GLOBAL_VALUE: MY_GLOBAL }); }, + port: 5000, log: true, // Optional - Specifies whether the server should use its default request logging. Useful for turning off default logging when providing custom logging middlewares chunkedResponse: true, // Optional - Opt-in to chunked transfer encoding, transferring the head, body and potential shoeboxes in separate chunks. Chunked transfer encoding should have a positive effect in particular when the app transfers a lot of data in the shoebox. }); diff --git a/package.json b/package.json index 88b718424..c7a761310 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,10 @@ "d3-cloud": "1.2.7", "dotenv": "16.0.2", "ember-d3": "0.5.1", - "exists-sync": "0.1.0", - "fastboot-app-server": "3.3.2" + "exists-sync": "0.1.0" }, "devDependencies": { + "fastboot-app-server": "4.1.4", "@babel/core": "7.24.7", "@babel/eslint-parser": "7.24.7", "@babel/plugin-proposal-decorators": "7.24.7", diff --git a/yarn.lock b/yarn.lock index a0e258c2f..ee222f2c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10071,25 +10071,17 @@ fast-sourcemap-concat@^2.1.0: source-map-url "^0.3.0" sourcemap-validator "^1.1.0" -fastboot-app-server@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/fastboot-app-server/-/fastboot-app-server-3.3.2.tgz#7aadc5bfdda7b51a20005c26404959c1d80d098b" - integrity sha512-jQ+nsmcLhR49Bx1J/74eN/9yez5abzutnck91FdctWgwHMghuuas82v5hoqrKYSVq8I1J5RwS0v7WcICNLH1oA== +fastboot-app-server@4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/fastboot-app-server/-/fastboot-app-server-4.1.4.tgz#f3f1353cda694f9ce9fb4b3d498bea1ef81eb789" + integrity sha512-1XEP0vnZ8GPqWqo7YNMzfNRtH+x/l2OcRpPjuP/07vL8qozHxakb79DU2lcnDqOAmqz5aCYAHCXRrYF7SLCw0g== dependencies: basic-auth "^2.0.1" chalk "^4.1.2" compression "^1.7.4" express "^4.17.2" - fastboot "3.3.2" - fastboot-express-middleware "3.3.2" - -fastboot-express-middleware@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/fastboot-express-middleware/-/fastboot-express-middleware-3.3.2.tgz#6d78de06f1db51f47b4f66658c651a61fcf5ca96" - integrity sha512-/Fgr29Q1bMDiv65BeCYmFR88otTg9QJYvmVIWrgkwWSkfya5h1XzCQYEz+VqyhWT1v+BQWq98SuyKfpNrL2cRA== - dependencies: - chalk "^4.1.2" - fastboot "3.3.2" + fastboot "4.1.5" + fastboot-express-middleware "4.1.2" fastboot-express-middleware@4.1.1: version "4.1.1" @@ -10099,6 +10091,14 @@ fastboot-express-middleware@4.1.1: chalk "^4.1.2" fastboot "4.1.1" +fastboot-express-middleware@4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/fastboot-express-middleware/-/fastboot-express-middleware-4.1.2.tgz#6a383c282fdc07ee3f90039701bb0dab11129179" + integrity sha512-vnzEBV7gZ3lSoGiqG/7+006nHNA3z+ZnU/5u9jPHtKpjH28yEbvZq6PnAeTu24UR98jZVR0pnFbfX0co+O9PeA== + dependencies: + chalk "^4.1.2" + fastboot "4.1.2" + fastboot-transform@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/fastboot-transform/-/fastboot-transform-0.1.3.tgz#7dea0b117594afd8772baa6c9b0919644e7f7dcd" @@ -10107,10 +10107,10 @@ fastboot-transform@^0.1.3: broccoli-stew "^1.5.0" convert-source-map "^1.5.1" -fastboot@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-3.3.2.tgz#bf1ac7b01937846b63423a88138e13eb50406d2e" - integrity sha512-2NKTW32GvEsDyBrdw1trW1JsbS+9/7sAQuKwkht12mNitimRrSKVLP2AxsM/HSXQE+aiET4XCfKdyeIy0kQbKQ== +fastboot@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-4.1.1.tgz#b686dc522ef805557ff76ded23328c486991cbaa" + integrity sha512-XG7YprsAuAGZrUDhmJ0NFuEP0gpWg9LZwGWSS1I5+f0ETHKPWqb4x59sN2rU1nvCEETBK70z68tLsWsl9daomg== dependencies: chalk "^4.1.2" cookie "^0.4.1" @@ -10120,10 +10120,23 @@ fastboot@3.3.2: simple-dom "^1.4.0" source-map-support "^0.5.21" -fastboot@4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-4.1.1.tgz#b686dc522ef805557ff76ded23328c486991cbaa" - integrity sha512-XG7YprsAuAGZrUDhmJ0NFuEP0gpWg9LZwGWSS1I5+f0ETHKPWqb4x59sN2rU1nvCEETBK70z68tLsWsl9daomg== +fastboot@4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-4.1.2.tgz#65627882d03962818f0f5331ca052d2da209ba98" + integrity sha512-VJLmF0xdCNwIIuA7DQtN1KTAKfEGsbZGJ0cfKh64h6DeMh3Fhr2FCCxkPh8zYqGoqzjXFdFbtk60WS3f6HKqBg== + dependencies: + chalk "^4.1.2" + cookie "^0.4.1" + debug "^4.3.3" + jsdom "^19.0.0" + resolve "^1.22.0" + simple-dom "^1.4.0" + source-map-support "^0.5.21" + +fastboot@4.1.5: + version "4.1.5" + resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-4.1.5.tgz#ed24af3ed68a1a4428e8ff1dd0106c7edb2065ab" + integrity sha512-2FkJWrpxgJjy5kLb3KrYp0pKdB4WgT/6qxtQO7ozYtQqMBOAARMnp59xp/Hdosa1cE2jslZgwDAv3v11OlQfAw== dependencies: chalk "^4.1.2" cookie "^0.4.1" From 9df96dfc0b6e7d3c35c83edd60c22021ef1c3556 Mon Sep 17 00:00:00 2001 From: Satyam Bajpai Date: Sun, 15 Sep 2024 02:17:24 +0530 Subject: [PATCH 2/2] chore: update docker file and cleanup --- Dockerfile | 13 +++---------- app/constants/urls.js | 11 +++-------- fastboot-server.js | 2 -- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index aa78c225d..d4b7e1965 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,13 @@ -# Utilize the Node.js 14 official image +# Utilize the Node.js 18 official image FROM node:18-alpine -USER root - # Set the working directory inside the container WORKDIR /app -# Copy the package.json and package-lock.json (if available) -# COPY package*.json ./ - -# Install the dependencies - - # Copy the rest of the application code COPY . . +# Install the dependencies RUN yarn install --frozen-lockfile # Build the Fastboot app @@ -23,5 +16,5 @@ RUN yarn build # Expose the port the Fastboot app runs on EXPOSE 5000 -# Define the command to run your Fastboot app +# Command to run the fastboot server after app gets build CMD ["node", "fastboot-server"] diff --git a/app/constants/urls.js b/app/constants/urls.js index 8609d7a71..de1f45141 100644 --- a/app/constants/urls.js +++ b/app/constants/urls.js @@ -14,10 +14,7 @@ const APP_URLS = { TASKS: `${SCHEME}my.${DOMAIN}/tasks`, IDENTITY: `${SCHEME}my.${DOMAIN}/identity`, MY_STATUS: `${SCHEME}my.${DOMAIN}`, - // API_BACKEND: `${SCHEME}api.${DOMAIN}`,hostWhitelist - - API_BACKEND: `http://localhost:3000`, - + API_BACKEND: `${SCHEME}api.${DOMAIN}`, DASHBOARD: `${SCHEME}dashboard.${DOMAIN}`, }, staging: { @@ -30,8 +27,7 @@ const APP_URLS = { TASKS: `${SCHEME}staging-my.${DOMAIN}/tasks`, IDENTITY: `${SCHEME}staging-my.${DOMAIN}/identity`, MY_STATUS: `${SCHEME}staging-my.${DOMAIN}`, - // API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, - API_BACKEND: `http://localhost:3000`, + API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, }, development: { HOME: `${SCHEME}staging-www.${DOMAIN}`, @@ -44,8 +40,7 @@ const APP_URLS = { IDENTITY: `${SCHEME}staging-my.${DOMAIN}/identity`, MY_STATUS: `${SCHEME}staging-my.${DOMAIN}`, DASHBOARD: `${SCHEME}staging-dashboard.${DOMAIN}`, - // API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, - API_BACKEND: `http://localhost:3000`, + API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`, }, test: { HOME: `${SCHEME}${DOMAIN}`, diff --git a/fastboot-server.js b/fastboot-server.js index 4d75de450..c2077ba3e 100644 --- a/fastboot-server.js +++ b/fastboot-server.js @@ -1,5 +1,3 @@ -// import FastBootAppServer from 'fastboot-app-server'; - // eslint-disable-next-line no-undef const FastBootAppServer = require('fastboot-app-server'); const MY_GLOBAL = 'MY GLOBAL';