Skip to content

Commit 0608f38

Browse files
committed
Dockerize the stop import script
1 parent 587d5e1 commit 0608f38

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed

README.md

+3-26
Original file line numberDiff line numberDiff line change
@@ -538,32 +538,7 @@ creates the source MSSQL database (_docker/mssql_init/populate.sql_) was changed
538538
539539
### Requirements
540540
541-
You need to have Python 3 installed on your system to run the script
542-
543-
#### Virtual environment
544-
545-
To run Python scripts with required libraries you should setup a virtual environment which contains the requirements for the script. To setup an environment, run:
546-
547-
`python3 -m venv LOCATION/OF/ENVIRONMENT/HERE`
548-
549-
Where you should replace the location with one you want to use. For example a directory under your home directory.
550-
To use the environment you can either source the virtual environment by running:
551-
552-
`source LOCATION/OF/ENVIRONMENT/HERE/bin/activate`
553-
554-
Which allows you to use the binaries directly as `python importer.py`
555-
556-
Or you can use the virtual environment python directly: `LOCATION/OF/ENVIRONMENT/HERE/bin/python importer.py`
557-
558-
#### Script setup
559-
560-
You need to run the `import.py` script using Python 3 and it requires the following libraries:
561-
562-
- pymssql
563-
- requests
564-
- simplejson
565-
566-
They can be installed by running `pip install -r requirements.txt`
541+
You need to have Docker installed on your system to run the script
567542
568543
### How to use
569544
@@ -586,3 +561,5 @@ JORE3_DATABASE_NAME=
586561
You should have run the base Jore3 importer first which ensures the Jore4 database has the required scheduled stop points. Then run the stop registry import script which will match scheduled stop points in the Jore4 routes database with stops in the Jore3 database and generate GraphQL mutations to Hasura/Tiamat according to the data. The script will also link the generated stop registry stops with the scheduled stop points by their NeTEx ID using Hasura for the mutation.
587562
588563
Running the script will produce multiple errors as there are many stops in the Jore3 database with overlapping validity. These can be ingored as only the most recent one is the one which ends up being imported.
564+
565+
To run the script simply run `run-stopimport.sh` in the stopimport directory, this will create and run a Docker container with the environment set up.

stopimport/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.12
2+
3+
WORKDIR /app
4+
COPY requirements.txt .
5+
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY importer.py .
9+
COPY .env .
10+
11+
CMD ["python", "importer.py"]
File renamed without changes.
File renamed without changes.

stopimport/run-stopimport.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
docker build -t stop-importer .
4+
docker run --network="host" stop-importer

0 commit comments

Comments
 (0)