Skip to content

Commit 2158c8f

Browse files
authored
Secrets for local development
Try to retrieve secrets for local development. Reference: CV2-2687.
1 parent 85bb110 commit 2158c8f

16 files changed

+67
-55
lines changed

.travis.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@ before_script:
1111
- export FALLBACK_BRANCH=$([ "$TRAVIS_BRANCH" == "master" ] && echo "main" || echo "develop")
1212
- git submodule foreach 'bash -c "git checkout develop ; git checkout $FALLBACK_BRANCH ; git checkout $TRAVIS_BRANCH ; exit 0"'
1313
- git submodule foreach git rev-parse --abbrev-ref HEAD
14-
# A couple fixes for Fetch
15-
- sed -i '/0.0.0/ i \'"${TAB}"'\until curl --silent -XGET --fail http://elasticsearch:9200; do printf \.\; sleep 1; done' fetch/Makefile
16-
- sed -i '/-c 5/ i \'"${TAB}"'\until curl --silent -XGET --fail http://elasticsearch:9200; do printf \.\; sleep 1; done' fetch/Makefile
1714
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
1815
script:
1916
- ./bin/first-build.sh
2017
- until curl --silent -I -f --fail http://localhost:3000 ; do printf .; sleep 1; done
2118
- sleep 120
22-
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3200)!= "200" )); then exit 1; fi;
23-
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3100)!= "200" )); then exit 1; fi;
24-
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3333)!= "200" )); then exit 1; fi;
25-
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000)!= "200" )); then exit 1; fi;
26-
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:8001)!= "200" )); then exit 1; fi;
19+
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3200)!= "200" )); then exit 1; fi; # Pender
20+
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3100)!= "200" )); then exit 1; fi; # Alegre
21+
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3333)!= "200" )); then exit 1; fi; # Check Web
22+
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000)!= "200" )); then exit 1; fi; # Check API
23+
- if (( $(curl -s -o /dev/null -w "%{http_code}" http://localhost:8001)!= "200" )); then exit 1; fi; # Check Search
2724
- docker ps --format '{{.Image}}' | sort >> docker_up_output.txt
2825
- diff docker_up_output.txt test/image_names.txt
2926
notifications:

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ This is a [Docker Compose](https://docs.docker.com/compose/) configuration that
2323
- Click "I already have an account" and login using your credentials
2424
- Enjoy Check! :tada:
2525

26-
**Note:** As you run the applications you may need credentials and configuration that are not provided by copying `.example` files during the initial build. You have to add the necessary credentials in the config files to use some features correctly:
27-
e.g: the [FACEBOOK APP ID](https://github.com/meedan/pender/blob/develop/config/config.yml.example#L64) to get Facebook social metrics and to run the Facebook related tests
26+
**Note 1:** For security reasons, not all credentials and configuration values are provided by copying `.example` files during the initial build. For Meedan members, you need to set your `AWS_PROFILE` environment variable, login to AWS (`aws sso login`) and then the script `bin/first-build.sh` will retrieve and set the required values for you. If you're not a Meedan member, you need to set at least the `google_client_id` and `google_client_secret` values in `check-api/config/config.yml`, [here is how you can get those](https://developers.google.com/identity/protocols/oauth2). Other optional features can be enabled by setting the required credentials, for example, the [FACEBOOK APP ID](https://github.com/meedan/pender/blob/develop/config/config.yml.example#L64) is needed to get Facebook social metrics and to run the Facebook related tests.
2827

28+
**Note 2:** For performance reasons, some services (that are not needed to run the application with its basic functionality) are disabled by default (e.g., commented in the Docker Compose file). If you need those services, please uncomment them in `docker-compose.yml`. If you may need to increase the amount of memory allocated for Docker in order for it to work.
2929

3030
## Available services and container names
3131

bin/first-build.sh

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
#!/bin/bash
2+
3+
# Go to the develop branch of each repository
24
git submodule foreach bash -c 'git checkout develop'
5+
6+
# Copy the example files
37
find . -name '*.example' -not -path '*apollo*' | while read f; do cp "$f" "${f%%.example}"; done
8+
9+
# Replace secrets (if you have access, login first with "aws sso login")
10+
replace_secret () {
11+
app=$1
12+
file=$2
13+
key=$3
14+
value=$(aws ssm get-parameter --region eu-west-1 --name "/local/$app/$key" | grep Value | sed 's/.*"Value": "\(.*\)",/\1/g')
15+
sed -i "s/$key: 'SECRET'/$key: '$value'/g" "$app/$file"
16+
}
17+
replace_secret 'check-api' 'config/config.yml' 'google_client_id'
18+
replace_secret 'check-api' 'config/config.yml' 'google_client_secret'
19+
20+
# Build & Run
421
docker-compose build
522
docker-compose up --abort-on-container-exit

check-api

Submodule check-api updated 123 files

check-search

check-web

Submodule check-web updated 70 files

docker-compose.yml

+32-32
Original file line numberDiff line numberDiff line change
@@ -301,38 +301,38 @@ services:
301301
DEPLOY_ENV: local
302302
networks:
303303
- dev
304-
fetch:
305-
volumes:
306-
- "./fetch:/app"
307-
build: fetch
308-
platform: linux/x86_64
309-
depends_on:
310-
- elasticsearch
311-
- redis
312-
- alegre
313-
- pender
314-
ports:
315-
- "9292:9292"
316-
env_file:
317-
- fetch/.env_file
318-
command: start_server
319-
networks:
320-
- dev
321-
fetch-background:
322-
volumes:
323-
- "./fetch:/app"
324-
platform: linux/x86_64
325-
depends_on:
326-
- elasticsearch
327-
- redis
328-
- alegre
329-
- pender
330-
build: fetch
331-
env_file:
332-
- fetch/.env_file
333-
command: run_worker
334-
networks:
335-
- dev
304+
# fetch:
305+
# volumes:
306+
# - "./fetch:/app"
307+
# build: fetch
308+
# platform: linux/x86_64
309+
# depends_on:
310+
# - elasticsearch
311+
# - redis
312+
# - alegre
313+
# - pender
314+
# ports:
315+
# - "9292:9292"
316+
# env_file:
317+
# - fetch/.env_file
318+
# command: start_server
319+
# networks:
320+
# - dev
321+
# fetch-background:
322+
# volumes:
323+
# - "./fetch:/app"
324+
# platform: linux/x86_64
325+
# depends_on:
326+
# - elasticsearch
327+
# - redis
328+
# - alegre
329+
# - pender
330+
# build: fetch
331+
# env_file:
332+
# - fetch/.env_file
333+
# command: run_worker
334+
# networks:
335+
# - dev
336336
mark:
337337
build: check-mark
338338
platform: linux/x86_64

test/image_names.txt

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ check_api-background
44
check_bots
55
check_check-slack-bot
66
check_elasticsearch
7-
check_fetch
8-
check_fetch-background
97
check_mark
108
check_narcissus
119
check_pender

0 commit comments

Comments
 (0)