diff --git a/keyserver/Dockerfile b/keyserver/Dockerfile --- a/keyserver/Dockerfile +++ b/keyserver/Dockerfile @@ -146,7 +146,14 @@ RUN yarn cleaninstall #------------------------------------------------------------------------------- -# STEP 7: WEBPACK BUILD +# STEP 7: GEOIP UPDATE +# We update the GeoIP database for mapping from IP address to timezone +#------------------------------------------------------------------------------- + +RUN yarn workspace keyserver docker-update-geoip + +#------------------------------------------------------------------------------- +# STEP 8: WEBPACK BUILD # We do this first so Docker doesn't rebuild when only keyserver files change #------------------------------------------------------------------------------- @@ -164,21 +171,21 @@ RUN yarn workspace web prod #------------------------------------------------------------------------------- -# STEP 8: COPY IN SOURCE FILES +# STEP 9: COPY IN SOURCE FILES # We run this later so the above layers are cached if only source files change #------------------------------------------------------------------------------- COPY --chown=comm . . #------------------------------------------------------------------------------- -# STEP 9: BUILD NODE ADDON +# STEP 10: BUILD NODE ADDON # Now that source files have been copied in, build rust-node-addon #------------------------------------------------------------------------------- RUN yarn workspace rust-node-addon build #------------------------------------------------------------------------------- -# STEP 10: RUN BUILD SCRIPTS +# STEP 11: RUN BUILD SCRIPTS # We need to populate keyserver/dist, among other things #------------------------------------------------------------------------------- @@ -186,7 +193,7 @@ RUN yarn workspace keyserver prod-build #------------------------------------------------------------------------------- -# STEP 11: RUN THE SERVER +# STEP 12: RUN THE SERVER # Actually run the Node.js keyserver using nvm #------------------------------------------------------------------------------- diff --git a/keyserver/package.json b/keyserver/package.json --- a/keyserver/package.json +++ b/keyserver/package.json @@ -10,8 +10,8 @@ "babel-build-comm-config": ". bash/source-nvm.sh && yarn --silent babel src/lib/utils/comm-config.js --out-dir dist/lib/utils/ --config-file ./babel.config.cjs", "babel-build": ". bash/source-nvm.sh && yarn --silent babel src/ --out-dir dist/ --config-file ./babel.config.cjs --verbose --ignore 'src/landing/flow-typed','src/landing/node_modules','src/landing/package.json','src/lib/flow-typed','src/lib/node_modules','src/lib/package.json','src/web/flow-typed','src/web/node_modules','src/web/package.json','src/web/dist','src/web/webpack.config.js','src/web/account-bar.react.js','src/web/app.react.js','src/web/calendar','src/web/chat','src/web/flow','src/web/loading-indicator.react.js','src/web/modals','src/web/root.js','src/web/router-history.js','src/web/script.js','src/web/selectors/chat-selectors.js','src/web/selectors/entry-selectors.js','src/web/splash','src/web/vector-utils.js','src/web/vectors.react.js'", "rsync": "rsync -rLpmuv --exclude '*/package.json' --exclude '*/node_modules/*' --include '*.json' --include '*.cjs' --include '*.node' --exclude '*.*' src/ dist/", - "prod-build": "yarn babel-build && yarn rsync && yarn update-geoip", - "update-geoip": "yarn script dist/scripts/update-geoip.js", + "prod-build": "yarn babel-build && yarn rsync", + "docker-update-geoip": "if [ \"$COMM_JSONCONFIG_secrets_geoip_license\" ]; then . bash/source-nvm.sh && node node_modules/geoip-lite/scripts/updatedb.js license_key=$(echo \"$COMM_JSONCONFIG_secrets_geoip_license\" | sed 's/{\"key\":\"\\([a-zA-Z0-9]*\\)\"}/\\1/'); fi", "prod": "node --trace-warnings --loader=./loader.mjs dist/keyserver", "dev-rsync": "yarn --silent chokidar --initial --silent -s 'src/**/*.json' 'src/**/*.cjs' -c 'yarn rsync > /dev/null 2>&1'", "dev": ". bash/source-nvm.sh && yarn concurrently --names=\"BABEL,RSYNC,NODEM\" -c \"bgBlue.bold,bgMagenta.bold,bgGreen.bold\" \"yarn babel-build --source-maps --watch\" \"yarn dev-rsync\" \". bash/source-nvm.sh && NODE_ENV=development nodemon -e js,json,cjs --watch dist --no-warnings=ExperimentalWarning --loader=./loader.mjs dist/keyserver\"", diff --git a/keyserver/src/cron/update-geoip-db.js b/keyserver/src/cron/update-geoip-db.js --- a/keyserver/src/cron/update-geoip-db.js +++ b/keyserver/src/cron/update-geoip-db.js @@ -60,4 +60,4 @@ }); } -export { updateGeoipDB, updateAndReloadGeoipDB }; +export { updateAndReloadGeoipDB }; diff --git a/keyserver/src/scripts/update-geoip.js b/keyserver/src/scripts/update-geoip.js deleted file mode 100644 --- a/keyserver/src/scripts/update-geoip.js +++ /dev/null @@ -1,16 +0,0 @@ -// @flow - -import { endScript } from './utils.js'; -import { updateGeoipDB } from '../cron/update-geoip-db.js'; - -async function main() { - try { - await updateGeoipDB(); - endScript(); - } catch (e) { - endScript(); - console.warn(e); - } -} - -main();