Skip to content

Commit 545c4a6

Browse files
committed
adding instructions for running inside Docker locally
1 parent 1f192d7 commit 545c4a6

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,49 @@ pytest test_ingest.py
128128
# Run all tests, show code coverage metrics
129129
pytest --cov=../ingest/
130130
```
131-
132131
For more, see <https://docs.pytest.org/en/stable/usage.html>.
133132

133+
## Testing in Docker
134+
If you have difficulties installing and configuring `scp-ingest-pipeline` due to hardware issues (e.g. Mac M1 chips),
135+
you can alternatively test locally by building the Docker image and then running any commands inside the container.
136+
There are some extra steps required, but this sidesteps the need to install packages locally.
137+
138+
### 1. Build the image
139+
Run the following command to build the testing Docker image locally (make sure Docker is running first):
140+
```
141+
docker build -t gcr.io/broad-singlecellportal-staging/ingest-pipeline:test-candidate .
142+
```
143+
### 2. Set up environment variables
144+
Run the following to pull database-specific secrets out of vault (passing in the path to your vault token):
145+
```
146+
source scripts/setup_mongo_dev.sh ~/.your-vault-token
147+
```
148+
Now run `env` to make sure you've set the following values:
149+
```
150+
MONGODB_USERNAME=single_cell
151+
DATABASE_NAME=single_cell_portal_development
152+
MONGODB_PASSWORD=<password>
153+
DATABASE_HOST=<ip address>
154+
```
155+
### 3. Print out your service account keyfile
156+
Run the following to export out your default service account JSON keyfile:
157+
```
158+
vault read -format=json secret/kdux/scp/development/$(whoami)/scp_service_account.json | jq .data > /tmp/keyfile.json
159+
```
160+
### 4. Start the Docker container
161+
Run the container, passing in the proper environment variables:
162+
```
163+
docker run --name scp-ingest-test -e MONGODB_USERNAME="$MONGODB_USERNAME" -e DATABASE_NAME="$DATABASE_NAME" \
164+
-e MONGODB_PASSWORD="$MONGODB_PASSWORD" -e DATABASE_HOST="$DATABASE_HOST" \
165+
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keyfile.json --rm -it \
166+
gcr.io/broad-singlecellportal-staging/ingest-pipeline:test-candidate bash
167+
```
168+
### 5. Copy keyfile to running container
169+
In a separate terminal window, copy the JSON keyfile from above to the expected location:
170+
```
171+
docker cp /tmp/keyfile.json scp-ingest-test:/tmp
172+
```
173+
You can now run any `ingest_pipeline.py` command you wish inside the container.
134174
# Use
135175

136176
Run this every time you start a new terminal to work on this project:

0 commit comments

Comments
 (0)