From 5f774da268b82c5777225a1193918306ee3f9ad9 Mon Sep 17 00:00:00 2001 From: Oleg Valter Date: Tue, 7 Jan 2025 10:25:11 +0300 Subject: [PATCH] made docker-compose configurable & added env file for persistence --- .env.example | 3 +++ .gitignore | 8 ++++++++ README.md | 16 ++++++++++------ docker-compose.yml | 3 +-- 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..392d9a1 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +COMPOSE_FILE=docker-compose.yml # Compose file to use +SEDD_OUTPUT_TYPE=json # Any output type supported by the program: json, sqlite +SPDLOG_LEVEL= # Sets the logging level diff --git a/.gitignore b/.gitignore index 54dd676..e9a61d0 100644 --- a/.gitignore +++ b/.gitignore @@ -175,3 +175,11 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ # }}} + +# env files +*.env +!*.example.env + +# Docker +docker-compose*.yml +!docker-compose.yml diff --git a/README.md b/README.md index 0fe8ca5..40cabf7 100644 --- a/README.md +++ b/README.md @@ -135,20 +135,24 @@ Once you've downloaded the data dumps, you may want to transform it into a more This section assumes you have Docker installed, with [docker-compose-v2](https://docs.docker.com/compose/migrate/). -From the root directory, run +A [default compose file](./docker-compose.yml) is provided for convenience. If you want to use a different one, set the `COMPOSE_FILE` environment variable in a custom `.env` file in the project's root directory, or provide it on the command line. To start the container (and build it if not done already), run: ```bash docker compose up ``` -This automatically binds `downloads` and `out` in the current working directory to the docker container. If you want to change these paths, you'll need to edit `docker-compose.yml` manually for now. +By default, this binds `downloads` and `out` in the current working directory to the container. If you want to change these paths, update the `volumes` attribute mapping of the `transformer` service in your compose file (or the default docker-compose.yml file if not using a custom one). -Additionally, the following environment variables are defined and forwarded to the build: +#### Environment variables -- `SEDD_OUTPUT_TYPE`: Any output type supported by the program. These are: `json`, `sqlite`. -- `SPDLOG_LEVEL`: Sets the logging level. Usually not necessary unless you want verbose output, or you're trying to debug something. +The following environment variables are used: -If you have a UNIX shell (i.e. not cmd or powershell; Windows users can use Git Bash), you can run +| Name | Values | Default | Description | +| ------------------ | -------------- | ------- | ------------------------- | +| `SEDD_OUTPUT_TYPE` | `json\|sqlite` | `json` | Any upported output type. | +| `SPDLOG_LEVEL` | log level | `info` | Sets the logging level. | + +If you want to override the defaults, either set them in a custom `.env` file in the project's root directory, or, if you have a UNIX shell (i.e. not cmd or PowerShell; Windows users can use Git Bash), you can explicitly provide them on the command line: ```bash SEDD_OUTPUT_TYPE=sqlite docker compose up diff --git a/docker-compose.yml b/docker-compose.yml index 9afe53b..b5af42e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,6 @@ services: - SPDLOG_LEVEL=${SPDLOG_LEVEL} user: "1000" volumes: - # Change these paths to use different source directories - # for the container + # Change these paths to use different directories for the container - ./downloads/:/app/downloads - ./out/:/app/out