Skip to content

Commit

Permalink
Adding files for local geolocation
Browse files Browse the repository at this point in the history
  • Loading branch information
sylviamclaughlin committed Sep 27, 2023
1 parent 2410542 commit 5a5ffff
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 29 deletions.
22 changes: 1 addition & 21 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
" >> /home/vscode/.aws/config
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 0 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ services:
VARIANT: "3.11"
INSTALL_NODE: "true"
NODE_VERSION: "lts/*"
LICENSE_KEY: '${MAXMIND_KEY}'

volumes:
- ..:/workspace:cached
command: sleep infinity
Expand Down
6 changes: 6 additions & 0 deletions .devcontainer/maxmind-create.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 17 additions & 4 deletions frontend/package-lock.json

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

1 change: 0 additions & 1 deletion frontend/src/scenes/geolocate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}

Expand Down

0 comments on commit 5a5ffff

Please sign in to comment.