From f7611b1057fa6c6d78d75c5404791a1f4ff59ff2 Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Tue, 23 Jan 2024 10:47:37 -0800 Subject: [PATCH 1/9] 0.1.1 --- README.md | 10 ++- deploy/staging/docker-compose.yml | 126 ++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 deploy/staging/docker-compose.yml diff --git a/README.md b/README.md index 3dfa2611..2243a3b5 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,15 @@ **npm run build** -# publish +### docker build -docker tag sphinx-tribes sphinxlightning/sphinx-tribes-frontend:0.1.0 +docker build -t sphinx-tribes-frontend . -docker push sphinxlightning/sphinx-tribes-frontend:0.1.0 +### docker publish + +docker tag sphinx-tribes sphinxlightning/sphinx-tribes-frontend:0.1.1 + +docker push sphinxlightning/sphinx-tribes-frontend:0.1.1 docker tag sphinx-tribes sphinxlightning/sphinx-tribes-frontend:latest diff --git a/deploy/staging/docker-compose.yml b/deploy/staging/docker-compose.yml new file mode 100644 index 00000000..47b09e49 --- /dev/null +++ b/deploy/staging/docker-compose.yml @@ -0,0 +1,126 @@ +version: "2" + +services: + reverse-proxy: + # The official v2 Traefik docker image + image: traefik:v2.2.1 + # Enables the web UI and tells Traefik to listen to docker + # command: --configFile=/home/ec2-user/sphinx-deploy/traefik.yaml + ports: + # The HTTP port + - 80:80 + # The Web UI (enabled by --api.insecure=true) + - 8080:8080 + # entrypoints + - 443:443 + - 8883:8883 + volumes: + # So that Traefik can listen to the Docker events + - /var/run/docker.sock:/var/run/docker.sock + - /home/ec2-user/sphinx-deploy/traefik.yaml:/etc/traefik/traefik.yaml + - /home/ec2-user/letsencrypt:/letsencrypt + environment: + - AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY + - AWS_REGION=$AWS_REGION + logging: + options: + max-size: 10m + ulimits: + nproc: 65535 + nofile: + soft: 1000000 + hard: 1000000 + + auth: + image: sphinx-auth + depends_on: + - reverse-proxy + labels: + - "traefik.enable=true" + - "traefik.http.routers.auth.rule=Host(`auth-test.sphinx.chat`)" + - "traefik.http.services.auth.loadbalancer.server.port=9090" + - "traefik.http.routers.auth.tls=true" + - "traefik.http.routers.auth.tls.certresolver=myresolver" + - "traefik.http.routers.auth.entrypoints=websecure" + restart: on-failure + environment: + - JWT_KEY=$JWT_KEY + - CLIENT_KEYS=$CLIENT_KEYS + - OAUTH_TIMEOUT=$OAUTH_TIMEOUT + - HOST=auth-test.sphinx.chat + + tribes: + image: sphinx-tribes + depends_on: + - auth + - reverse-proxy + labels: + - "traefik.enable=true" + - "traefik.http.routers.tribes.rule=Host(`api.tribes-test.sphinx.chat`) || Host(`api.people-test.sphinx.chat`) || Host(`api.community-test.sphinx.chat`)" + - "traefik.http.services.tribes.loadbalancer.server.port=5002" + - "traefik.http.routers.tribes.tls=true" + - "traefik.http.routers.tribes.tls.certresolver=myresolver" + - "traefik.http.routers.tribes.entrypoints=websecure" + restart: on-failure + environment: + - DATABASE_URL=$DATABASE_URL + - PODCAST_INDEX_SECRET=$PODCAST_INDEX_SECRET + - PODCAST_INDEX_KEY=$PODCAST_INDEX_KEY + - YOUTUBE_KEY=$YOUTUBE_KEY + - GITHUB_TOKEN=$GITHUB_TOKEN + - LN_SERVER_BASE_URL=https://people-test.sphinx.chat + - LN_JWT_KEY=$LN_JWT_KEY + - RELAY_URL=$RELAY_URL + - RELAY_AUTH_KEY=$RELAY_AUTH_KEY + - RELAY_URL_BACKUP=$RELAY_URL_BACKUP + - RELAY_AUTH_KEY_BACKUP=$RELAY_AUTH_KEY_BACKUP + - HOST=people-test.sphinx.chat + - REDIS_URL=$REDIS_URL + - ADMIN_PUBKEYS=$ADMINS + - ADMINS=$ADMINS + - AWS_SECRET_ACCESS=$AWS_SECRET_ACCESS_KEY + - AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID + - AWS_REGION=us-east-1 + - S3_BUCKET_NAME=sphinx-tribes + - S3_FOLDER_NAME=metrics + - S3_URL=https://sphinx-tribes.s3.amazonaws.com + ulimits: + nproc: 65535 + nofile: + soft: 1000000 + hard: 1000000 + + tribes-frontend: + image: stakwork/sphinx-tribes-frontend:latest + depends_on: + - tribes + - reverse-proxy + labels: + - "traefik.enable=true" + - "traefik.http.routers.tribes.rule=Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)" + - "traefik.http.services.tribes.loadbalancer.server.port=80" + - "traefik.http.routers.tribes.tls=true" + - "traefik.http.routers.tribes.tls.certresolver=myresolver" + - "traefik.http.routers.tribes.entrypoints=websecure" + restart: on-failure + + mqtt: + image: sphinx-mqtt + depends_on: + - auth + - reverse-proxy + labels: + - "traefik.enable=true" + - "traefik.tcp.routers.mqtt.rule=HostSNI(`tribes-test.sphinx.chat`)" + - "traefik.tcp.services.mqtt.loadbalancer.server.port=1883" + - "traefik.tcp.routers.mqtt.tls=true" + - "traefik.tcp.routers.mqtt.tls.certresolver=myresolver" + - "traefik.tcp.routers.mqtt.entrypoints=mqttsecure" + - "traefik.tcp.routers.mqtt.service=mqtt" + restart: on-failure + ulimits: + nproc: 65535 + nofile: + soft: 1000000 + hard: 1000000 From 07485db8e35ca5f97c313912fe87d30ecce22f3d Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Tue, 23 Jan 2024 11:17:35 -0800 Subject: [PATCH 2/9] fix docker path --- deploy/staging/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/staging/docker-compose.yml b/deploy/staging/docker-compose.yml index 47b09e49..4f260b67 100644 --- a/deploy/staging/docker-compose.yml +++ b/deploy/staging/docker-compose.yml @@ -92,7 +92,7 @@ services: hard: 1000000 tribes-frontend: - image: stakwork/sphinx-tribes-frontend:latest + image: sphinxlightning/sphinx-tribes-frontend:latest depends_on: - tribes - reverse-proxy From 410acd65daf7341b13f1eb109de88353024d3e2b Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Tue, 23 Jan 2024 12:17:07 -0800 Subject: [PATCH 3/9] fix docker compose file --- README.md | 6 +++--- deploy/staging/docker-compose.yml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2243a3b5..8c1d99cc 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ docker build -t sphinx-tribes-frontend . ### docker publish -docker tag sphinx-tribes sphinxlightning/sphinx-tribes-frontend:0.1.1 +docker tag sphinx-tribes-frontend sphinxlightning/sphinx-tribes-frontend:0.1.2 -docker push sphinxlightning/sphinx-tribes-frontend:0.1.1 +docker push sphinxlightning/sphinx-tribes-frontend:0.1.2 -docker tag sphinx-tribes sphinxlightning/sphinx-tribes-frontend:latest +docker tag sphinx-tribes-frontend sphinxlightning/sphinx-tribes-frontend:latest docker push sphinxlightning/sphinx-tribes-frontend:latest \ No newline at end of file diff --git a/deploy/staging/docker-compose.yml b/deploy/staging/docker-compose.yml index 4f260b67..11b89b9d 100644 --- a/deploy/staging/docker-compose.yml +++ b/deploy/staging/docker-compose.yml @@ -98,11 +98,11 @@ services: - reverse-proxy labels: - "traefik.enable=true" - - "traefik.http.routers.tribes.rule=Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)" - - "traefik.http.services.tribes.loadbalancer.server.port=80" - - "traefik.http.routers.tribes.tls=true" - - "traefik.http.routers.tribes.tls.certresolver=myresolver" - - "traefik.http.routers.tribes.entrypoints=websecure" + - "traefik.http.routers.tribes-frontend.rule=Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)" + - "traefik.http.services.tribes-frontend.loadbalancer.server.port=80" + - "traefik.http.routers.tribes-frontend.tls=true" + - "traefik.http.routers.tribes-frontend.tls.certresolver=myresolver" + - "traefik.http.routers.tribes-frontend.entrypoints=websecure" restart: on-failure mqtt: From b0df7337ae23b3230407f84c703af4c3ca411c6a Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Tue, 23 Jan 2024 13:08:11 -0800 Subject: [PATCH 4/9] nginx config --- Dockerfile | 1 + README.md | 4 ++-- deploy/nginx.conf | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 deploy/nginx.conf diff --git a/Dockerfile b/Dockerfile index ef01f946..d8cb759b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,5 @@ COPY . . RUN yarn run build FROM nginx:alpine +COPY --from=build /usr/src/app/deploy/nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /usr/src/app/build /usr/share/nginx/html diff --git a/README.md b/README.md index 8c1d99cc..c749fc22 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ docker build -t sphinx-tribes-frontend . ### docker publish -docker tag sphinx-tribes-frontend sphinxlightning/sphinx-tribes-frontend:0.1.2 +docker tag sphinx-tribes-frontend sphinxlightning/sphinx-tribes-frontend:0.1.3 -docker push sphinxlightning/sphinx-tribes-frontend:0.1.2 +docker push sphinxlightning/sphinx-tribes-frontend:0.1.3 docker tag sphinx-tribes-frontend sphinxlightning/sphinx-tribes-frontend:latest diff --git a/deploy/nginx.conf b/deploy/nginx.conf new file mode 100644 index 00000000..7bfc27a0 --- /dev/null +++ b/deploy/nginx.conf @@ -0,0 +1,41 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + ## Your only path reference. + root /usr/share/nginx/html; + + ## This should be in your http block and if it is, it's not needed here. + index index.html; + + autoindex off; + + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location = /manifest.json { + allow all; + log_not_found off; + access_log off; + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location / { + if (!-e $request_filename){ + rewrite ^(.*)$ /index.html break; + } + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { + expires max; + log_not_found off; + } +} \ No newline at end of file From 4942c614246e320d724647f06a86400c6fb14399 Mon Sep 17 00:00:00 2001 From: Tushar Vyas <89837102+Vayras@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:48:28 +0530 Subject: [PATCH 5/9] auto Populate Org --- src/people/main/FocusView.tsx | 81 +++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/src/people/main/FocusView.tsx b/src/people/main/FocusView.tsx index a386850d..dd60eb19 100644 --- a/src/people/main/FocusView.tsx +++ b/src/people/main/FocusView.tsx @@ -4,7 +4,6 @@ import { cloneDeep } from 'lodash'; import { observer } from 'mobx-react-lite'; import { FocusViewProps } from 'people/interfaces'; import { EuiGlobalToastList } from '@elastic/eui'; -import { Organization } from 'store/main'; import { Box } from '@mui/system'; import { useStores } from '../../store'; import Form from '../../components/form/bounty'; @@ -17,11 +16,7 @@ import { import WantedSummary from '../widgetViews/summaries/WantedSummary'; import { useIsMobile } from '../../hooks'; import { dynamicSchemasByType } from '../../components/form/schema'; -import { - convertLocaleToNumber, - extractRepoAndIssueFromIssueUrl, - toCapitalize -} from '../../helpers'; +import { convertLocaleToNumber, extractRepoAndIssueFromIssueUrl } from '../../helpers'; import { B, BWrap } from './style'; // selected bounty popup window @@ -60,12 +55,52 @@ function FocusedView(props: FocusViewProps) { const isTorSave = canEdit && main.isTorSave(); - const userOrganizations = main.dropDownOrganizations.length - ? main.dropDownOrganizations.map((org: Organization) => ({ - label: toCapitalize(org.name), - value: org.uuid - })) - : []; + //this code block can be used to get the real org values + // const [userOrganizations,setUserOrganizations] = useState({}); + // const getOrg =async()=>{ + // const response = await main.getOrganizations() + // const mappedResponse = response.map((org: Organization) => ({ + // label: org.name, + // value: org.uuid + // })) + // setUserOrganizations(mappedResponse) + // } + // getOrg() + + const [orgName, setOrgName] = useState([]); + const getOrganization = async () => { + const urlParts = window.location.href.split('/bounties/'); + const uuid = urlParts.length > 1 ? urlParts[1] : null; + + if (!uuid) { + console.error('No UUID found in the URL'); + return; + } + + try { + const response = await main.getUserOrganizationByUuid(uuid); + console.log(response, 'res'); + + if (response && response.uuid && response.name) { + // Creating an array with an object containing label and value + const orgDetails = [ + { + label: response.name, + value: response.uuid + } + ]; + setOrgName(orgDetails); + } else { + console.error('Response does not have the expected structure'); + } + } catch (error) { + console.error('Error fetching organization:', error); + } + }; + + useEffect(() => { + getOrganization(); + }); function isNotHttps(url: string | undefined) { if (main.isTorSave() || url?.startsWith('http://')) { @@ -192,6 +227,9 @@ function FocusedView(props: FocusViewProps) { // body.description = description; newBody.title = newBody.one_sentence_summary; + + // save repo to cookies for autofill in form + ui.setLastGithubRepo(newBody.ticket_url); } } catch (e) { throw githubError; @@ -263,8 +301,20 @@ function FocusedView(props: FocusViewProps) { props?.ReCallBounties(); } + // set user organizations + if (config?.schema?.[0]?.['defaultSchema']?.[0]?.['options']) { + config.schema[0]['defaultSchema'][0]['options'] = orgName; + } + let initialValues: any = {}; + let altInitialValue = {}; + if (window.location.href.includes('/org')) { + altInitialValue = { + org_uuid: `"ck95pe04nncjnaefo08g"` || orgName[0]?.value + }; + } + const personInfo = canEdit ? ui.meInfo : person; // set initials here @@ -310,6 +360,8 @@ function FocusedView(props: FocusViewProps) { initialValues[s.name] = wanted[s.name]; }); } + } else { + initialValues = altInitialValue; } } @@ -347,11 +399,6 @@ function FocusedView(props: FocusViewProps) { } } - // set user organizations - if (config?.schema?.[0]?.['defaultSchema']?.[0]?.['options']) { - config.schema[0]['defaultSchema'][0]['options'] = userOrganizations; - } - return (
Date: Wed, 24 Jan 2024 13:39:40 +0530 Subject: [PATCH 6/9] Update FocusView.tsx --- src/people/main/FocusView.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/people/main/FocusView.tsx b/src/people/main/FocusView.tsx index dd60eb19..63611014 100644 --- a/src/people/main/FocusView.tsx +++ b/src/people/main/FocusView.tsx @@ -66,12 +66,10 @@ function FocusedView(props: FocusViewProps) { // setUserOrganizations(mappedResponse) // } // getOrg() - + const urlParts = window.location.href.split('/bounties/'); + const uuid = urlParts.length > 1 ? urlParts[1] : null; const [orgName, setOrgName] = useState([]); const getOrganization = async () => { - const urlParts = window.location.href.split('/bounties/'); - const uuid = urlParts.length > 1 ? urlParts[1] : null; - if (!uuid) { console.error('No UUID found in the URL'); return; @@ -311,7 +309,7 @@ function FocusedView(props: FocusViewProps) { let altInitialValue = {}; if (window.location.href.includes('/org')) { altInitialValue = { - org_uuid: `"ck95pe04nncjnaefo08g"` || orgName[0]?.value + org_uuid:uuid }; } From be052e389d3666ab40e83e31c8c9fcdd3830d38b Mon Sep 17 00:00:00 2001 From: Tushar Vyas <89837102+Vayras@users.noreply.github.com> Date: Thu, 25 Jan 2024 01:10:07 +0530 Subject: [PATCH 7/9] removed api from backend calls --- src/config/host.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/host.ts b/src/config/host.ts index 0a46e565..1fa0de0c 100644 --- a/src/config/host.ts +++ b/src/config/host.ts @@ -2,7 +2,9 @@ const internalDockerHosts = ['localhost:13007', 'localhost:13000']; const externalDockerHosts = ['localhost:23007', 'localhost:23000']; export function getHost(): string { - const host = window.location.host.includes('localhost') ? 'localhost:5002' : `api.${window.location.host}`; + const host = window.location.host.includes('localhost') + ? 'localhost:5002' + : `${window.location.host}`; return host; } From 7377d48de8006062377c46b5250b815ff3dd8086 Mon Sep 17 00:00:00 2001 From: Tushar Vyas <89837102+Vayras@users.noreply.github.com> Date: Thu, 25 Jan 2024 01:12:45 +0530 Subject: [PATCH 8/9] host.ts fix --- src/config/host.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/config/host.ts b/src/config/host.ts index 1fa0de0c..51a0f319 100644 --- a/src/config/host.ts +++ b/src/config/host.ts @@ -2,9 +2,7 @@ const internalDockerHosts = ['localhost:13007', 'localhost:13000']; const externalDockerHosts = ['localhost:23007', 'localhost:23000']; export function getHost(): string { - const host = window.location.host.includes('localhost') - ? 'localhost:5002' - : `${window.location.host}`; + const host = window.location.host.includes('localhost') ? 'localhost:5002' : window.location.host; return host; } From 7d3edca043bfd778b4493c042116c6fdb39ab973 Mon Sep 17 00:00:00 2001 From: Tushar Vyas <89837102+Vayras@users.noreply.github.com> Date: Thu, 25 Jan 2024 01:18:09 +0530 Subject: [PATCH 9/9] prettier fix --- src/people/main/FocusView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/people/main/FocusView.tsx b/src/people/main/FocusView.tsx index 63611014..7cef5bec 100644 --- a/src/people/main/FocusView.tsx +++ b/src/people/main/FocusView.tsx @@ -309,7 +309,7 @@ function FocusedView(props: FocusViewProps) { let altInitialValue = {}; if (window.location.href.includes('/org')) { altInitialValue = { - org_uuid:uuid + org_uuid: uuid }; }