-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create automatic importer and persist data
- Loading branch information
Showing
6 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
# docker-metabase w/MongoDB backend | ||
To get started, do the following: | ||
- Start metabase`docker-compose up` | ||
- In another terminal, start another Mongo container: `docker run -it mongo:3.2 bash` | ||
- In another terminal, find the container ID of the container just started: `docker ps` | ||
- Copy file into container: `docker cp ./file.csv CONTAINER_ID:/` | ||
- Connect container to Mongo network: `docker network connect metabase_stack CONTAINER_ID` | ||
- Inspect network and get IP of Mongo container: `docker network Inspect metabase_stack` | ||
- Run the import tool, replacing IP and filename: `mongoimport --host=172.19.0.2 -d groupme -c groupme --type csv --file ./file.csv --headerline` | ||
- Open http://localhost:3000 to get to the Metabase setup wizard. When setting up the database, use the IP address from the previous step. No authentication is set up. | ||
- Drag CSV files to import into MongoDB into `importer/files_to_import/`. If you have different kinds of files, you may need to make modifications to the import script. | ||
- Look at the environment variables for the importer in `docker-compose.yml`. Change the database and collection names if desired. | ||
- For the first run only, change IMPORT_RUN to "true". Then change it back to "false" so you don't have new documents being imported every time you restart the containers. | ||
- Start metabase: `docker-compose up` | ||
- Open http://localhost:3000 to get to the Metabase setup wizard. When setting up the database, use "mongodb" as the IP address for MongoDB and the data from the environment variables. No authentication is set up. | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM mongo:3.2 | ||
|
||
# Create data directory and switch to it | ||
RUN mkdir /import-data | ||
WORKDIR /import-data | ||
|
||
# Copy files to import into the container | ||
COPY ./import.sh /import-data | ||
COPY files_to_import /import-data | ||
|
||
CMD ["/bin/bash", "./import.sh"] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ "$IMPORT_RUN" = true ] ; then | ||
for filename in *.csv; | ||
do | ||
mongoimport --host=mongodb -d $MONGO_DATABASE -c $MONGO_COLLECTION --type csv --file $filename --headerline; | ||
done | ||
fi |