mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-03-21 17:44:49 -05:00
chore: add logging to ip2location and add token to build scripts
This commit is contained in:
parent
73d6a74a35
commit
ab80f48dde
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
|
|
@ -53,6 +53,8 @@ jobs:
|
|||
push: ${{ env.SHOULD_PUSH_IMAGE }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
secrets: |
|
||||
"ip2location-token=${{ secrets.IP2LOCATION_TOKEN }}"
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ RUN --mount=type=bind,source=package.json,target=package.json \
|
|||
npm ci
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
RUN --mount=type=secret,id=ip2location-token,env=PN_ACT_CONFIG_IP2LOCATION_TOKEN \
|
||||
npm run build
|
||||
|
||||
# * Running the final application
|
||||
FROM base AS final
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"build": "npm run lint && npm run clean && npx tsc && npx tsc-alias && npm run copy-static && node ./scripts/download-ip2location-databases.js",
|
||||
"download-geoip-db": "node ./scripts/download-ip2location-databases.js",
|
||||
"build": "npm run lint && npm run clean && npx tsc && npx tsc-alias && npm run copy-static && npm run download-geoip-db",
|
||||
"clean": "rimraf ./dist",
|
||||
"copy-static": "copyfiles -e \"src/**/*.ts\" -u 1 \"src/**/*\" dist",
|
||||
"start": "node .",
|
||||
|
|
@ -87,4 +88,4 @@
|
|||
"ndarray": "^1.0.19",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,12 +18,15 @@ const databases = {
|
|||
|
||||
async function main() {
|
||||
if (!process.env.PN_ACT_CONFIG_IP2LOCATION_TOKEN) {
|
||||
// * Optional
|
||||
console.warn('IP2Location token not found in environment variables. Skipping database download.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Downloading ${Object.keys(databases).length} IP2Location databases...`);
|
||||
|
||||
for (const name in databases) {
|
||||
const database = databases[name];
|
||||
console.log(`Downloading ${database.file_name}...`);
|
||||
const response = await fetch(`https://www.ip2location.com/download/?token=${process.env.PN_ACT_CONFIG_IP2LOCATION_TOKEN}&file=${name}`);
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user