Skip to content

Commit

Permalink
feat: remove gp data (#43)
Browse files Browse the repository at this point in the history
* feat: remove gp extensions

* feat: update migrations and envs

* feat: remove gp mentions

* feat: remove gp collections

* feat: rename docker image
  • Loading branch information
alexey-yarmosh authored May 24, 2024
1 parent b24861b commit c26ac5f
Show file tree
Hide file tree
Showing 196 changed files with 202 additions and 100,560 deletions.
19 changes: 0 additions & 19 deletions .env.development.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,6 @@ AUTH_GITHUB_IDENTIFIER_KEY=id
# GitHub API
# A classic token (not scoped), required permissions are: read:org, read:user
GITHUB_ACCESS_TOKEN=
# Generated during enabling of webhooks and passed to the app, to validate requests
# Create the webhook at https://github.com/sponsors/jsdelivr/dashboard/webhooks/441768912/edit#deliveries
# See WEBHOOK_FLOW_ID in .env.example for the webhook URL
GITHUB_WEBHOOK_SECRET=

# Globalping API
GLOBALPING_URL=https://api.globalping.io/v1
GP_SYSTEM_KEY=

# Geonames API
GEONAMES_USERNAME=

# App
CREDITS_PER_DOLLAR=2000
CREDITS_PER_ADOPTED_PROBE_DAY=150
ADOPTED_PROBES_CHECK_TIME_MAX_DEVIATION_MINS=5
# To trigger credits assignment probe need to be online >20 hours during the day. Current "Adopted probes status CRON" is "*/10 * * * *", which is 6 times an hour
# So required value is 20 * 6 = 120
ADOPTED_PROBES_REQUIRED_ONLINE_TIMES=120

# Are updated during `npm run init`
AUTH_GITHUB_DEFAULT_ROLE_ID=
Expand Down
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ DB_DATABASE=
DB_USER=
DB_PASSWORD=

# ID that will be used for the flow. Any valid UUID.
# The final URL for the webhook is ${host}/flows/trigger/${WEBHOOK_FLOW_ID}
WEBHOOK_FLOW_ID=e8a4c2b2-3ed4-4ddc-b98e-34c1952c2323
DIRECTUS_URL=

ADMIN_EMAIL=
Expand Down
19 changes: 0 additions & 19 deletions .env.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,6 @@ AUTH_GITHUB_IDENTIFIER_KEY=id
# GitHub API
# A classic token (not scoped), required permissions are: read:org, read:user
GITHUB_ACCESS_TOKEN=
# Generated during enabling of webhooks and passed to the app, to validate requests
# Create the webhook at https://github.com/sponsors/jsdelivr/dashboard/webhooks/441768912/edit#deliveries
# See WEBHOOK_FLOW_ID in .env.example for the webhook URL
GITHUB_WEBHOOK_SECRET=

# Globalping API
GLOBALPING_URL=https://api.globalping.io/v1
GP_SYSTEM_KEY=

# Geonames API
GEONAMES_USERNAME=

# App
CREDITS_PER_DOLLAR=2000
CREDITS_PER_ADOPTED_PROBE_DAY=150
ADOPTED_PROBES_CHECK_TIME_MAX_DEVIATION_MINS=5
# To trigger credits assignment probe need to be online >20 hours during the day. Current "Adopted probes status CRON" is "*/10 * * * *", which is 6 times an hour
# So required value is 20 * 6 = 120
ADOPTED_PROBES_REQUIRED_ONLINE_TIMES=120

# Are updated during `npm run init`
AUTH_GITHUB_DEFAULT_ROLE_ID=
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: jsdelivr/dashboard/dashboard-staging
name: jsdelivr/dashboard/dash-directus-staging
username: jsdelivr
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: jsdelivr/dashboard/dashboard
name: jsdelivr/dashboard/dash-directus
username: jsdelivr
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
Expand Down
138 changes: 2 additions & 136 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,153 +30,19 @@ RUN npm ci
COPY ./src/extensions/token-value .
RUN npm run build

# Build gh-webhook-handler
FROM node:18-alpine AS builder-05
WORKDIR /builder/src/extensions/operations/gh-webhook-handler
ADD ./src/extensions/operations/gh-webhook-handler/package.json ./src/extensions/operations/gh-webhook-handler/package-lock.json ./
RUN npm ci
COPY ./src/extensions/operations/gh-webhook-handler .
RUN npm run build

# Build sponsors-cron-handler
FROM node:18-alpine AS builder-06
WORKDIR /builder/src/extensions/operations/sponsors-cron-handler
ADD ./src/extensions/operations/sponsors-cron-handler/package.json ./src/extensions/operations/sponsors-cron-handler/package-lock.json ./
RUN npm ci
COPY ./src/extensions/operations/sponsors-cron-handler .
RUN npm run build

# Build modules/probes-adapter
FROM node:18-alpine AS builder-07
WORKDIR /builder/src/extensions/modules/probes-adapter
ADD ./src/extensions/modules/probes-adapter/package.json ./src/extensions/modules/probes-adapter/package-lock.json ./
RUN npm ci
COPY ./src/extensions/modules/probes-adapter .
RUN npm run build

# Build endpoints/adoption-code
FROM node:18-alpine AS builder-08
WORKDIR /builder/src/extensions/endpoints/adoption-code
ADD ./src/extensions/endpoints/adoption-code/package.json ./src/extensions/endpoints/adoption-code/package-lock.json ./
RUN npm ci
COPY ./src/extensions/endpoints/adoption-code .
RUN npm run build

# Build hooks/adopted-probe
FROM node:18-alpine AS builder-09
WORKDIR /builder/src/extensions/lib
ADD ./src/extensions/lib/package.json ./src/extensions/lib/package-lock.json ./
RUN npm ci
COPY ./src/extensions/lib .
WORKDIR /builder/src/extensions/hooks/adopted-probe
ADD ./src/extensions/hooks/adopted-probe/package.json ./src/extensions/hooks/adopted-probe/package-lock.json ./
RUN npm ci
COPY ./src/extensions/hooks/adopted-probe .
RUN npm run build

# Build hooks/sign-in
FROM node:18-alpine AS builder-10
WORKDIR /builder/src/extensions/hooks/sign-in
ADD ./src/extensions/hooks/sign-in/package.json ./src/extensions/hooks/sign-in/package-lock.json ./
RUN npm ci
COPY ./src/extensions/hooks/sign-in .
RUN npm run build

# Build endpoints/sync-github-data
FROM node:18-alpine AS builder-11
WORKDIR /builder/src/extensions/endpoints/sync-github-data
ADD ./src/extensions/endpoints/sync-github-data/package.json ./src/extensions/endpoints/sync-github-data/package-lock.json ./
RUN npm ci
COPY ./src/extensions/endpoints/sync-github-data .
RUN npm run build

# Build interfaces/github-username
FROM node:18-alpine AS builder-12
WORKDIR /builder/src/extensions/interfaces/github-username
ADD ./src/extensions/interfaces/github-username/package.json ./src/extensions/interfaces/github-username/package-lock.json ./
RUN npm ci
COPY ./src/extensions/interfaces/github-username .
RUN npm run build

# Build adopted-probes-status-cron-handler
FROM node:18-alpine AS builder-13
WORKDIR /builder/src/extensions/operations/adopted-probes-status-cron-handler
ADD ./src/extensions/operations/adopted-probes-status-cron-handler/package.json ./src/extensions/operations/adopted-probes-status-cron-handler/package-lock.json ./
RUN npm ci
COPY ./src/extensions/operations/adopted-probes-status-cron-handler .
RUN npm run build

# Build adopted-probes-credits-cron-handler
FROM node:18-alpine AS builder-14
WORKDIR /builder/src/extensions/operations/adopted-probes-credits-cron-handler
ADD ./src/extensions/operations/adopted-probes-credits-cron-handler/package.json ./src/extensions/operations/adopted-probes-credits-cron-handler/package-lock.json ./
RUN npm ci
COPY ./src/extensions/operations/adopted-probes-credits-cron-handler .
RUN npm run build

# Build interfaces/gp-tags
FROM node:18-alpine AS builder-15
WORKDIR /builder/src/extensions/interfaces/gp-tags
ADD ./src/extensions/interfaces/gp-tags/package.json ./src/extensions/interfaces/gp-tags/package-lock.json ./
RUN npm ci
COPY ./src/extensions/interfaces/gp-tags .
RUN npm run build

# Build operations/remove-banned-users-cron-handler
FROM node:18-alpine AS builder-16
FROM node:18-alpine AS builder-05
WORKDIR /builder/src/extensions/operations/remove-banned-users-cron-handler
ADD ./src/extensions/operations/remove-banned-users-cron-handler/package.json ./src/extensions/operations/remove-banned-users-cron-handler/package-lock.json ./
RUN npm ci
COPY ./src/extensions/operations/remove-banned-users-cron-handler .
RUN npm run build

# Build hooks/gp-tokens
FROM node:18-alpine AS builder-17
WORKDIR /builder/src/extensions/hooks/gp-tokens
ADD ./src/extensions/hooks/gp-tokens/package.json ./src/extensions/hooks/gp-tokens/package-lock.json ./
RUN npm ci
COPY ./src/extensions/hooks/gp-tokens .
RUN npm run build

# Build hooks/directus-users
FROM node:18-alpine AS builder-18
WORKDIR /builder/src/extensions/hooks/directus-users
ADD ./src/extensions/hooks/directus-users/package.json ./src/extensions/hooks/directus-users/package-lock.json ./
RUN npm ci
COPY ./src/extensions/hooks/directus-users .
RUN npm run build

# Build hooks/location-verrides
FROM node:18-alpine AS builder-19
WORKDIR /builder/src/extensions/lib
ADD ./src/extensions/lib/package.json ./src/extensions/lib/package-lock.json ./
RUN npm ci
COPY ./src/extensions/lib .
WORKDIR /builder/src/extensions/hooks/location-overrides
ADD ./src/extensions/hooks/location-overrides/package.json ./src/extensions/hooks/location-overrides/package-lock.json ./
RUN npm ci
COPY ./src/extensions/hooks/location-overrides .
RUN npm run build

FROM directus/directus:10.9.3

COPY --from=builder-01 /builder/src/extensions/hooks/jsd-purge-tokens/dist/* /directus/extensions/hooks/jsd-purge-tokens/
COPY --from=builder-02 /builder/src/extensions/hooks/sign-up/dist/* /directus/extensions/hooks/sign-up/
COPY --from=builder-03 /builder/src/extensions/interfaces/token/dist/* /directus/extensions/interfaces/token/
COPY --from=builder-04 /builder/src/extensions/token-value/dist/* /directus/extensions/directus-extension-token-value/dist/
COPY --from=builder-04 /builder/src/extensions/token-value/package.json /directus/extensions/directus-extension-token-value/
COPY --from=builder-05 /builder/src/extensions/operations/gh-webhook-handler/dist/* /directus/extensions/operations/gh-webhook-handler/
COPY --from=builder-06 /builder/src/extensions/operations/sponsors-cron-handler/dist/* /directus/extensions/operations/sponsors-cron-handler/
COPY --from=builder-07 /builder/src/extensions/modules/probes-adapter/dist/* /directus/extensions/modules/probes-adapter/
COPY --from=builder-08 /builder/src/extensions/endpoints/adoption-code/dist/* /directus/extensions/endpoints/adoption-code/
COPY --from=builder-09 /builder/src/extensions/hooks/adopted-probe/dist/* /directus/extensions/hooks/adopted-probe/
COPY --from=builder-10 /builder/src/extensions/hooks/sign-in/dist/* /directus/extensions/hooks/sign-in/
COPY --from=builder-11 /builder/src/extensions/endpoints/sync-github-data/dist/* /directus/extensions/endpoints/sync-github-data/
COPY --from=builder-12 /builder/src/extensions/interfaces/github-username/dist/* /directus/extensions/interfaces/github-username/
COPY --from=builder-13 /builder/src/extensions/operations/adopted-probes-status-cron-handler/dist/* /directus/extensions/operations/adopted-probes-status-cron-handler/
COPY --from=builder-14 /builder/src/extensions/operations/adopted-probes-credits-cron-handler/dist/* /directus/extensions/operations/adopted-probes-credits-cron-handler/
COPY --from=builder-15 /builder/src/extensions/interfaces/gp-tags/dist/* /directus/extensions/interfaces/gp-tags/
COPY --from=builder-16 /builder/src/extensions/operations/remove-banned-users-cron-handler/dist/* /directus/extensions/operations/remove-banned-users-cron-handler/
COPY --from=builder-17 /builder/src/extensions/hooks/gp-tokens/dist/* /directus/extensions/hooks/gp-tokens/
COPY --from=builder-18 /builder/src/extensions/hooks/directus-users/dist/* /directus/extensions/hooks/directus-users/
COPY --from=builder-19 /builder/src/extensions/hooks/location-overrides/dist/* /directus/extensions/hooks/location-overrides/
COPY --from=builder-05 /builder/src/extensions/operations/remove-banned-users-cron-handler/dist/* /directus/extensions/operations/remove-banned-users-cron-handler/
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dashboard
# jsDelivr dashboard directus

## Prod first deploy

Expand Down Expand Up @@ -54,12 +54,12 @@ sudo apt -y install haproxy
# Configure and start haproxy
sudo chmod a+w /etc/haproxy/haproxy.cfg
cat <<EOF | sudo tee -a /etc/haproxy/haproxy.cfg > /dev/null
frontend gp_fe
frontend jsd_fe
bind *:80
default_backend gp_be
default_backend jsd_be
backend gp_be
server server1 127.0.0.1:8055
backend jsd_be
server server1 127.0.0.1:8056
EOF
sudo systemctl stop haproxy
sudo systemctl start haproxy
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ services:
- MARIADB_PASSWORD=password
- MARIADB_ROOT_PASSWORD=root
ports:
- "3306:3306"
- "3307:3306"
volumes:
- ./config/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-u", "directus", "-ppassword"]
interval: 3s
timeout: 2s
retries: 10
directus:
dash-directus:
depends_on:
mariadb:
condition: service_healthy
Expand All @@ -26,4 +26,4 @@ services:
env_file:
- .env.development
ports:
- "8055:8055"
- "8056:8055"
2 changes: 1 addition & 1 deletion knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default _.merge({}, ...[ 'development' ].map((environment) => {
user: 'directus',
password: 'password',
database: 'directus',
port: 3306,
port: 3307,
},
pool: {
min: 0,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "dashboard",
"name": "dash-directus",
"version": "1.0.0",
"license": "OSL-3.0",
"description": "jsDelivr dashboard",
"description": "jsDelivr dashboard directus",
"private": true,
"type": "module",
"dependencies": {
Expand Down Expand Up @@ -41,10 +41,10 @@
},
"repository": {
"type": "git",
"url": "[email protected]:jsdelivr/dashboard.git"
"url": "[email protected]:jsdelivr/dash-directus.git"
},
"bugs": {
"url": "https://github.com/jsdelivr/dashboard/issues"
"url": "https://github.com/jsdelivr/dash-directus/issues"
},
"engines": {
"node": "^18.15.0"
Expand Down
6 changes: 3 additions & 3 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ if [ "$is_dev_mode" = true ]; then

perl -pi -e "s/AUTH_GITHUB_DEFAULT_ROLE_ID=.*/AUTH_GITHUB_DEFAULT_ROLE_ID=$user_role_id/" .env.development

docker compose stop directus
docker compose stop dash-directus

docker compose up -d directus
docker compose up -d dash-directus

./scripts/wait-for.sh -t 60 http://localhost:8055/admin/login
./scripts/wait-for.sh -t 60 http://localhost:8056/admin/login

npm run seed
else
Expand Down
36 changes: 0 additions & 36 deletions seeds/development/admin-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,9 @@ export const seed = async (knex) => {
]);

await knex('directus_presets').insert([{
user: admin.id,
collection: 'gp_adopted_probes',
layout_query: { tabular: { fields: [ 'id', 'userId.first_name', 'ip', 'city', 'country', 'name', 'status', 'onlineTimesToday' ] } },
icon: 'bookmark',
},
{
user: admin.id,
collection: 'jsd_purge_tokens',
layout_query: { tabular: { fields: [ 'id', 'user_created', 'name', 'value', 'expire', 'origins', 'date_last_used' ] } },
icon: 'bookmark',
},
{
user: admin.id,
collection: 'gp_tokens',
layout_query: { tabular: { fields: [ 'id', 'user_created', 'name', 'value', 'expire', 'origins', 'date_last_used' ] } },
icon: 'bookmark',
},
{
user: admin.id,
collection: 'gp_credits',
layout_query: { tabular: { fields: [ 'id', 'user_id.first_name', 'amount' ] } },
icon: 'bookmark',
},
{
user: admin.id,
collection: 'gp_credits_additions',
layout_query: { tabular: { fields: [ 'id', 'github_id', 'amount', 'comment', 'adopted_probe.ip' ] } },
icon: 'bookmark',
},
{
user: admin.id,
collection: 'gp_credits_deductions',
layout_query: { tabular: { fields: [ 'id', 'user_id.first_name', 'amount', 'date' ] } },
icon: 'bookmark',
},
{
user: admin.id,
collection: 'sponsors',
layout_query: { tabular: { fields: [ 'id', 'github_login', 'monthly_amount', 'last_earning_date' ] } },
icon: 'bookmark',
}]);
};
Loading

0 comments on commit c26ac5f

Please sign in to comment.