algolia / docsearch-scraper

DocSearch - Scraper
https://docsearch.algolia.com/
Other
305 stars 106 forks source link

Need help with creating a Docker Compose file #568

Closed deepfriedbrain closed 2 years ago

deepfriedbrain commented 2 years ago

I'm trying to create a docker compose file to run the Docsearch scraper container but I'm not able to get it to work correctly. For CONFIG, if I use $$(cat ./docsearch-config.json | jq -r tostring), I get "ValueError: CONFIG is not a valid JSON". But if I run it on the command line (on MacOS) and hard-code the JSON string into the yaml file, then it works.

Here's my docker-compose file:

version: '3'
services:
docsearch:
  image: algolia/docsearch-scraper
  environment:
    - CONFIG=$$(cat ./docsearch-config.json | jq -r tostring)
    - APPLICATION_ID=<app_id>
    - API_KEY=<api_key>

Can someone help me create a proper docker compose file? Thanks.

shortcuts commented 2 years ago
- CONFIG=$$(cat ./docsearch-config.json | jq -r tostring)
+ CONFIG=$(cat ./docsearch-config.json | jq -r tostring)

You have an extra $, see command substitution

shortcuts commented 2 years ago

Thinking again, I don't even think it's possible to run the bash command as it's yaml here

You can do it in two step

CONFIG=$(cat ./docsearch-config.json | jq -r tostring) && docker-compose up -d
shortcuts commented 2 years ago

(closing as it's not a scraper related issue)

deepfriedbrain commented 2 years ago

Thanks for your help. That $$ was intentional because I was getting an error about $ not being valid in yaml.

Also note that && is not needed. Just prepending CONFIG to docker-compose works as well.

CONFIG=$(cat ./docsearch-config.json | jq -r tostring) docker-compose -f docsearch-compose.yml up
shortcuts commented 2 years ago

Thanks for your help. That $$ was intentional because I was getting an error about $ not being valid in yaml.

Yep make sense, it's expected to read variables but having ${myEnvVar} with the solution above would work

Also note that && is not needed. Just prepending CONFIG to docker-compose works as well.

oops typo :D