diff --git a/.deploy/k8s/k8s-manifest.dev.yaml b/.deploy/k8s/k8s-manifest.dev.yaml index b1430904b..348e5c3b3 100644 --- a/.deploy/k8s/k8s-manifest.dev.yaml +++ b/.deploy/k8s/k8s-manifest.dev.yaml @@ -19,7 +19,7 @@ spec: - name: http protocol: TCP port: 443 - targetPort: 3000 + targetPort: 3030 --- kind: Deployment @@ -106,5 +106,5 @@ spec: value: '$NEXT_PUBLIC_CAPTCHA_SITE_KEY' ports: - - containerPort: 3000 + - containerPort: 3030 protocol: TCP diff --git a/.deploy/k8s/k8s-manifest.prod.yaml b/.deploy/k8s/k8s-manifest.prod.yaml index 555f85805..4d2b9b7e3 100644 --- a/.deploy/k8s/k8s-manifest.prod.yaml +++ b/.deploy/k8s/k8s-manifest.prod.yaml @@ -19,7 +19,7 @@ spec: - name: http protocol: TCP port: 443 - targetPort: 3000 + targetPort: 3030 --- kind: Deployment @@ -106,5 +106,5 @@ spec: value: '$NEXT_PUBLIC_CAPTCHA_SITE_KEY' ports: - - containerPort: 3000 + - containerPort: 3030 protocol: TCP diff --git a/.render/render.dev.yaml b/.render/render.dev.yaml index 43c9791ca..162ca0ab4 100644 --- a/.render/render.dev.yaml +++ b/.render/render.dev.yaml @@ -14,7 +14,7 @@ services: - key: NEXT_PUBLIC_GAUZY_API_SERVER_URL value: https://apidev.ever.team - key: GAUZY_API_SERVER_URL - value: https://apidev.ever.team/api + value: https://apidev.ever.team - key: NEXT_PUBLIC_GA_MEASUREMENT_ID sync: false - key: NEXT_PUBLIC_CAPTCHA_SITE_KEY diff --git a/Dockerfile b/Dockerfile index ddf296336..67bed2e4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -104,8 +104,8 @@ COPY --from=build /app/apps/web/.next/static ./apps/web/.next/static COPY --from=build /app/apps/web/public ./apps/web/public # Start the server by default, this can be overwritten at runtime -EXPOSE 3000 +EXPOSE 3030 -ENV PORT=3000 +ENV PORT=3030 CMD [ "node", "./apps/web/server.js" ] diff --git a/Layerfile b/Layerfile index 5df270bf5..207fbddd0 100644 --- a/Layerfile +++ b/Layerfile @@ -2,18 +2,18 @@ FROM vm/ubuntu:18.04 # install the latest version of Docker, as in the official Docker installation tutorial. RUN apt-get update && \ - apt-get install ca-certificates curl gnupg lsb-release && \ - sudo mkdir -p /etc/apt/keyrings && \ - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \ - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |\ - sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \ - apt-get update && \ - apt-get install docker-ce docker-ce-cli containerd.io + apt-get install ca-certificates curl gnupg lsb-release && \ + sudo mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \ + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |\ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \ + apt-get update && \ + apt-get install docker-ce docker-ce-cli containerd.io RUN REPEATABLE docker pull everco/ever-teams-webapp RUN REPEATABLE (docker rm ever-teams --force || true) &&\ - docker run --name ever-teams -d -p 3000:3000 everco/ever-teams-webapp && sleep 5 + docker run --name ever-teams -d -p 3030:3030 everco/ever-teams-webapp && sleep 5 -EXPOSE WEBSITE localhost:3000 +EXPOSE WEBSITE localhost:3030 diff --git a/Layerfile.build b/Layerfile.build index 13f4cd554..600f3a28a 100644 --- a/Layerfile.build +++ b/Layerfile.build @@ -18,6 +18,6 @@ COPY . . RUN REPEATABLE docker build -t ever-teams . RUN REPEATABLE (docker rm ever-teams --force || true) &&\ - docker run --name ever-teams -d -p 3000:3000 ever-teams && sleep 5 + docker run --name ever-teams -d -p 3030:3030 ever-teams && sleep 5 -EXPOSE WEBSITE localhost:3000 +EXPOSE WEBSITE localhost:3030 diff --git a/Layerfile.node b/Layerfile.node index 30fd5915e..304fd2a24 100644 --- a/Layerfile.node +++ b/Layerfile.node @@ -19,4 +19,4 @@ RUN REPEATABLE cd apps/web && yarn install && yarn build RUN BACKGROUND yarn start:web -EXPOSE WEBSITE localhost:3000 +EXPOSE WEBSITE localhost:3030 diff --git a/README.md b/README.md index 836fc8283..3c033950b 100644 --- a/README.md +++ b/README.md @@ -91,25 +91,25 @@ Please refer to our official [Platform Documentation](https://docs.ever.team) (W -### Quick Start with our live APIs +### Quick Start with our public live APIs 1. Clone this repo 2. Run `yarn install` -3. Run `yarn build:web` -4. Run `yarn start:web` +3. Run `yarn build:web && yarn start:web` OR `yarn start:web:dev` +4. Open in in your Browser Notes: -- by default, Ever Teams web frontend will be connected to our production [Ever Gauzy API](https://github.com/ever-co/ever-gauzy) API endpoint . You can change it in environment variables `GAUZY_API_SERVER_URL` and `NEXT_PUBLIC_GAUZY_API_SERVER_URL`, see below how to run with a Self-hosted Backend. +- by default, Ever Teams web frontend will be connected to our production [Ever Gauzy API](https://github.com/ever-co/ever-gauzy) API endpoint . You can change it in environment variables `GAUZY_API_SERVER_URL` and `NEXT_PUBLIC_GAUZY_API_SERVER_URL`, see below how to run with a Self-hosted Backend. ### Run with a Self-hosted Backend 1. Download and run the Ever Gauzy Server setup () or run the server manually (see ). You can also run only Ever Gauzy APIs (manually), see . For getting starting instructions, it's best to check the Ever Gauzy [README](https://github.com/ever-co/ever-gauzy/blob/develop/README.md) file. 2. Clone this repo -3. After you get the API or Server running, make sure you set the environment variables `GAUZY_API_SERVER_URL` and `NEXT_PUBLIC_GAUZY_API_SERVER_URL` in Ever Teams .env file (see for example). +3. After you get the API or Server running, make sure you set the environment variables `GAUZY_API_SERVER_URL` and `NEXT_PUBLIC_GAUZY_API_SERVER_URL` in Ever Teams .env file (see ). For example, you can set those env vars to if Gauzy API running on that host & port. 4. Run `yarn install` -5. Run `yarn build:web` -6. Run `yarn start:web` +5. Run `yarn build:web && yarn start:web` OR `yarn start:web:dev` +6. Open in in your Browser #### Notes @@ -159,7 +159,7 @@ WIP ### Koyeb -[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?name=ever-teams&type=docker&builder=dockerfile&image=ghcr.io/ever-co/ever-teams-webapp:latest&env[PORT]=3000&ports=3000;http;/) +[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?name=ever-teams&type=docker&builder=dockerfile&image=ghcr.io/ever-co/ever-teams-webapp:latest&env[PORT]=3030&ports=3030;http;/) ### Northflank diff --git a/apps/web/.env b/apps/web/.env index e8d086fee..2fe6875eb 100644 --- a/apps/web/.env +++ b/apps/web/.env @@ -1,7 +1,7 @@ RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=false -GAUZY_API_SERVER_URL=https://api.ever.team/api -NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.ever.team +GAUZY_API_SERVER_URL=https://api.ever.team # http://localhost:3000 +NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.ever.team # http://localhost:3000 NEXT_PUBLIC_GA_MEASUREMENT_ID= # CAPTCHA Settings diff --git a/apps/web/README.md b/apps/web/README.md index c87e0421d..d0ebc4f8e 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -10,11 +10,11 @@ npm run dev yarn dev ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +Open [http://localhost:3030](http://localhost:3030) with your browser to see the result. You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. -[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. +[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3030/api/hello](http://localhost:3030/api/hello). This endpoint can be edited in `pages/api/hello.ts`. The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. @@ -22,8 +22,8 @@ The `pages/api` directory is mapped to `/api/*`. Files in this directory are tre To learn more about Next.js, take a look at the following resources: -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! diff --git a/apps/web/app/constants.ts b/apps/web/app/constants.ts index 1fdd241e7..69a72c590 100644 --- a/apps/web/app/constants.ts +++ b/apps/web/app/constants.ts @@ -37,7 +37,9 @@ export const RECAPTCHA_SITE_KEY = getNextPublicEnv( export const RECAPTCHA_SECRET_KEY = process.env.CAPTCHA_SECRET_KEY; // Gauzy Server URL -export const GAUZY_API_SERVER_URL = process.env.GAUZY_API_SERVER_URL || 'https://api.ever.team/api'; +export const GAUZY_API_SERVER_URL = process.env.GAUZY_API_SERVER_URL + ? process.env.GAUZY_API_SERVER_URL.replace('/api', '') + '/api' + : 'https://api.ever.team' + '/api'; export const GAUZY_API_BASE_SERVER_URL = getNextPublicEnv( 'NEXT_PUBLIC_GAUZY_API_SERVER_URL', diff --git a/apps/web/app/services/server/fetch.ts b/apps/web/app/services/server/fetch.ts index 6193890d5..32d56cb05 100644 --- a/apps/web/app/services/server/fetch.ts +++ b/apps/web/app/services/server/fetch.ts @@ -33,7 +33,7 @@ export function serverFetch({ datas['body'] = JSON.stringify(body); } - return fetch((GAUZY_API_SERVER_URL || '') + path, { + return fetch(GAUZY_API_SERVER_URL + path, { ...datas, ...(init || {}), headers: { diff --git a/apps/web/env.js b/apps/web/env.js new file mode 100644 index 000000000..269981410 --- /dev/null +++ b/apps/web/env.js @@ -0,0 +1,30 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +require('dotenv').config(); + +const port = process.env.PORT || 3030; + +console.log(`NextJs is starting on Port 3030. You can open https://localhost:${port} to view it in the browser.`); + +const isProduction = process.env.NODE_ENV === 'production'; + +const isSentryEnabled = isProduction && process.env.SENTRY_DSN; + +console.log(`isProduction: ${isProduction}`); + +console.log(`isSentryEnabled: ${isSentryEnabled}`); + +if (process.env.GAUZY_API_SERVER_URL) { + console.log( + `Using Gauzy API from NextJs backend defined by GAUZY_API_SERVER_URL: ${process.env.GAUZY_API_SERVER_URL}` + ); +} else { + console.warn(`GAUZY_API_SERVER_URL not defined`); +} + +if (process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL) { + console.log( + `Using Gauzy API directly from frontend defined by NEXT_PUBLIC_GAUZY_API_SERVER_URL: ${process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL}` + ); +} else { + console.warn(`Using Gauzy API via backend API 'proxy' because env NEXT_PUBLIC_GAUZY_API_SERVER_URL not defined`); +} diff --git a/apps/web/next.config.js b/apps/web/next.config.js index f3561a349..547e6654c 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -2,10 +2,10 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path'); const withNextIntl = require('next-intl/plugin')(); - -console.log(`NEXT_PUBLIC_GAUZY_API_SERVER_URL: ${process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL}`); +const { withSentryConfig } = require('@sentry/nextjs'); const isProduction = process.env.NODE_ENV === 'production'; + const isSentryEnabled = isProduction && process.env.SENTRY_DSN; const sentryConfig = isSentryEnabled && { @@ -62,25 +62,23 @@ const nextConfig = { }; // Injected content via Sentry wizard below -// const { withSentryConfig } = require('@sentry/nextjs'); - -// const sentryWebpackPluginOptions = { -// org: process.env.SENTRY_ORG || 'ever-co', -// project: process.env.SENTRY_PROJECT || 'ever-teams-web', +const sentryWebpackPluginOptions = { + org: process.env.SENTRY_ORG || 'ever-co', + project: process.env.SENTRY_PROJECT || 'ever-teams-web', -// // An auth token is required for uploading source maps. -// authToken: process.env.SENTRY_AUTH_TOKEN, + // An auth token is required for uploading source maps. + authToken: process.env.SENTRY_AUTH_TOKEN, -// silent: true, // Suppresses all logs + silent: true, // Suppresses all logs -// dryRun: process.env.NODE_ENV !== 'production' + dryRun: process.env.NODE_ENV !== 'production' -// // Additional config options for the Sentry Webpack plugin. -// // Keep in mind that https://github.com/getsentry/sentry-webpack-plugin#options. -// }; + // Additional config options for the Sentry Webpack plugin. + // Keep in mind that https://github.com/getsentry/sentry-webpack-plugin#options. +}; // Make sure adding Sentry options is the last code to run before exporting -// module.exports = process.env.NODE_ENV === "production" && process.env.SENTRY_DSN -// ? withSentryConfig(nextConfig, sentryWebpackPluginOptions) : nextConfig - -module.exports = withNextIntl(nextConfig); +module.exports = + process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN + ? withSentryConfig(withNextIntl(nextConfig), sentryWebpackPluginOptions) + : withNextIntl(nextConfig); diff --git a/apps/web/package.json b/apps/web/package.json index 0007f70ae..20f58c06a 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -9,9 +9,9 @@ }, "private": true, "scripts": { - "dev": "yarn next dev", + "dev": "yarn node env.js && yarn next dev -p 3030", "build": "yarn next build", - "start": "yarn next start", + "start": "yarn node env.js && yarn next start -p 3030", "lint": "yarn next lint" }, "dependencies": { @@ -112,6 +112,7 @@ "@types/react-google-recaptcha": "^2.1.5", "eslint": "^8.28.0", "eslint-config-next": "^14.0.4", + "dotenv": "^16.4.1", "typescript": "^4.9.4" }, "prettier": { diff --git a/apps/web/project.json b/apps/web/project.json index 509f2d885..3f2eb0f60 100644 --- a/apps/web/project.json +++ b/apps/web/project.json @@ -21,7 +21,7 @@ "options": { "buildTarget": "web:build", "dev": true, - "port": 3000, + "port": 3030, "hostname": "localhost" }, "configurations": { diff --git a/fly.toml b/fly.toml index 080eb74c9..41b2701b0 100644 --- a/fly.toml +++ b/fly.toml @@ -12,7 +12,7 @@ kill_timeout = "5m0s" image = "ghcr.io/ever-co/ever-teams-webapp:latest" [http_service] - internal_port = 3000 + internal_port = 3030 force_https = true auto_stop_machines = true auto_start_machines = true diff --git a/northflank-template.json b/northflank-template.json index 64de68c2d..1caa83873 100644 --- a/northflank-template.json +++ b/northflank-template.json @@ -1,59 +1,59 @@ { - "apiVersion": "v1", - "spec": { - "kind": "Workflow", - "spec": { - "type": "sequential", - "steps": [ - { - "kind": "DeploymentService", - "spec": { - "deployment": { - "instances": 1, - "docker": { - "configType": "default" - }, - "external": { - "imagePath": "ghcr.io/ever-co/ever-teams-webapp:latest" - } - }, - "runtimeEnvironment": {}, - "runtimeFiles": {}, - "billing": { - "deploymentPlan": "nf-compute-10" - }, - "name": "ever-teams-web", - "ports": [ - { - "internalPort": 3000, - "protocol": "HTTP", - "public": true, - "name": "p01", - "domains": [], - "security": { - "policies": [], - "credentials": [] - }, - "disableNfDomain": false - } - ] - } - } - ] - } - }, - "name": "ever-teams-template", - "description": "Open Work and Project Management Platform.", - "project": { - "spec": { - "name": "Ever Teams Template", - "region": "europe-west", - "description": "Open Work and Project Management Platform.", - "color": "#3826A6", - "networking": { - "allowedIngressProjects": [] - } - } - }, - "$schema": "https://api.northflank.com/v1/schemas/template" -} \ No newline at end of file + "apiVersion": "v1", + "spec": { + "kind": "Workflow", + "spec": { + "type": "sequential", + "steps": [ + { + "kind": "DeploymentService", + "spec": { + "deployment": { + "instances": 1, + "docker": { + "configType": "default" + }, + "external": { + "imagePath": "ghcr.io/ever-co/ever-teams-webapp:latest" + } + }, + "runtimeEnvironment": {}, + "runtimeFiles": {}, + "billing": { + "deploymentPlan": "nf-compute-10" + }, + "name": "ever-teams-web", + "ports": [ + { + "internalPort": 3030, + "protocol": "HTTP", + "public": true, + "name": "p01", + "domains": [], + "security": { + "policies": [], + "credentials": [] + }, + "disableNfDomain": false + } + ] + } + } + ] + } + }, + "name": "ever-teams-template", + "description": "Open Work and Project Management Platform.", + "project": { + "spec": { + "name": "Ever Teams Template", + "region": "europe-west", + "description": "Open Work and Project Management Platform.", + "color": "#3826A6", + "networking": { + "allowedIngressProjects": [] + } + } + }, + "$schema": "https://api.northflank.com/v1/schemas/template" +} diff --git a/package.json b/package.json index 4ff60052e..031b7e5b3 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,10 @@ "config": "yarn ts-node ./.scripts/configure.ts", "config:dev": "yarn run config -- --environment=dev", "config:prod": "yarn run config -- --environment=prod", - "dev:web": "cd apps/web && yarn run dev", "start": "yarn build && yarn concurrently --raw --kill-others \"yarn start:web\"", "start:prod": "yarn build && yarn concurrently --raw --kill-others \"yarn start:web:prod\"", "start:web": "cd apps/web && yarn run start", + "start:web:dev": "cd apps/web && yarn run dev", "start:web:forever": "yarn run config:dev && forever start ng serve web --disable-host-check --host 0.0.0.0", "start:web:pm2": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 yarn build:web && yarn ts-node ./apps/web/src/pm2bootstrap.ts", "start:web:prod": "yarn run config:prod && yarn ng serve web --configuration production --disable-host-check --host 0.0.0.0 --prod", diff --git a/render.yaml b/render.yaml index 9d3e8444c..f1876734e 100644 --- a/render.yaml +++ b/render.yaml @@ -14,7 +14,7 @@ services: - key: NEXT_PUBLIC_GAUZY_API_SERVER_URL value: https://api.ever.team - key: GAUZY_API_SERVER_URL - value: https://api.ever.team/api + value: https://api.ever.team - key: NEXT_PUBLIC_GA_MEASUREMENT_ID sync: false - key: NEXT_PUBLIC_CAPTCHA_SITE_KEY diff --git a/yarn.lock b/yarn.lock index b549a6c89..9f8923b24 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11012,6 +11012,11 @@ dotenv@^16.0.3, dotenv@~16.3.1: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== +dotenv@^16.4.1: + version "16.4.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.1.tgz#1d9931f1d3e5d2959350d1250efab299561f7f11" + integrity sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ== + dotenv@^8.2.0: version "8.6.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b"