From 5a5ffff73b736bfdeb252714e0b2492ed637d4dd Mon Sep 17 00:00:00 2001 From: Sylvia McLaughlin <85905333+sylviamclaughlin@users.noreply.github.com> Date: Wed, 27 Sep 2023 00:44:58 +0000 Subject: [PATCH] Adding files for local geolocation --- .devcontainer/Dockerfile | 22 +--------------------- .devcontainer/devcontainer.json | 3 ++- .devcontainer/docker-compose.yml | 2 -- .devcontainer/maxmind-create.sh | 6 ++++++ frontend/package-lock.json | 21 +++++++++++++++++---- frontend/src/scenes/geolocate/index.jsx | 1 - 6 files changed, 26 insertions(+), 29 deletions(-) create mode 100755 .devcontainer/maxmind-create.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b3458103..42454785 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -43,24 +43,4 @@ RUN echo "\n\ [default]\n\ region=ca-central-1\n\ output=json\n\ - " >> /home/vscode/.aws/config - -# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. -# COPY requirements.txt /tmp/pip-tmp/ -# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ -# && rm -rf /tmp/pip-tmp -# - -WORKDIR /workspace - -# Setup Maxmind -ARG LICENSE_KEY - -RUN pwd - -RUN mkdir -p ./app/geodb -RUN wget -O "./app/geodb/GeoLite2-City.tar.gz" "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$LICENSE_KEY&suffix=tar.gz" -RUN tar -xzvf ./app/geodb/GeoLite2-City.tar.gz -C ./app/geodb -RUN cp ./app/geodb/GeoLite2-City_*/GeoLite2-City.mmdb ./app/geodb/GeoLite2-City.mmdb -# RUN rm -rf /app/geodb/GeoLite2-City_* -# RUN rm /app/geodb/GeoLite2-City.tar.gz \ No newline at end of file + " >> /home/vscode/.aws/config \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0497b42d..434ed12c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -40,7 +40,8 @@ ], // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. + //use postcommand to create the maxmind db + 'postCreateCommand': '.devcontainer/maxmind-create.sh', "remoteUser": "vscode", "features": { "ghcr.io/devcontainers/features/aws-cli:1": { diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index bee0dc91..116502f5 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -20,8 +20,6 @@ services: VARIANT: "3.11" INSTALL_NODE: "true" NODE_VERSION: "lts/*" - LICENSE_KEY: '${MAXMIND_KEY}' - volumes: - ..:/workspace:cached command: sleep infinity diff --git a/.devcontainer/maxmind-create.sh b/.devcontainer/maxmind-create.sh new file mode 100755 index 00000000..034c65b1 --- /dev/null +++ b/.devcontainer/maxmind-create.sh @@ -0,0 +1,6 @@ +mkdir -p /workspace/app/geodb/ +wget -O "/workspace/app/geodb/GeoLite2-City.tar.gz" "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_KEY&suffix=tar.gz" +tar -xzvf /workspace/app/geodb/GeoLite2-City.tar.gz -C /workspace/app/geodb/ +cp /workspace/app/geodb/GeoLite2-City_*/GeoLite2-City.mmdb /workspace/app/geodb/GeoLite2-City.mmdb +rm -fr /workspace/app/geodb/GeoLite2-City_* +rm /workspace/app/geodb/GeoLite2-City.tar.gz \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 98e5bdf2..a48ce7c0 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -9424,6 +9424,19 @@ "node": ">=6" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/formik": { "version": "2.4.5", "resolved": "https://registry.npmjs.org/formik/-/formik-2.4.5.tgz", @@ -17754,16 +17767,16 @@ } }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=14.17" + "node": ">=4.2.0" } }, "node_modules/unbox-primitive": { diff --git a/frontend/src/scenes/geolocate/index.jsx b/frontend/src/scenes/geolocate/index.jsx index cf6618b1..c81749a7 100644 --- a/frontend/src/scenes/geolocate/index.jsx +++ b/frontend/src/scenes/geolocate/index.jsx @@ -20,7 +20,6 @@ const geoUrl = // call the backend API to fetch the location data using the /geolocate endpoint // if we are in development we need to call the API using the full URL function fetchLocationData(inputValue) { - //return fetch(process.env.REACT_APP_API_URL + '/geolocate/' + inputValue); return fetch(`${window.origin}/geolocate/${inputValue}`); }