forked from dlops-io/data-versioning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-shell.sh
executable file
·38 lines (32 loc) · 1.13 KB
/
docker-shell.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
set -e
export BASE_DIR=$(pwd)
export SECRETS_DIR=$(pwd)/../secrets/
export GCS_BUCKET_NAME="data-versioning-test"
export GCP_PROJECT="ac215-project"
export GCP_ZONE="us-central1-a"
echo "Creating network"
docker network inspect data-versioning-network >/dev/null 2>&1 || docker network create data-versioning-network
echo "Building image"
docker build -t data-version-cli -f Dockerfile .
echo "Running container"
docker run --rm --name data-version-cli -ti \
--privileged \
--cap-add SYS_ADMIN \
--device /dev/fuse \
-v "$BASE_DIR":/app \
-v "$SECRETS_DIR":/secrets \
-v ~/.gitconfig:/etc/gitconfig \
-e GOOGLE_APPLICATION_CREDENTIALS=/secrets/data-service-account.json \
-e GCP_PROJECT=$GCP_PROJECT \
-e GCP_ZONE=$GCP_ZONE \
-e GCS_BUCKET_NAME=$GCS_BUCKET_NAME \
--network data-versioning-network data-version-cli \
bash -c "
gcloud auth activate-service-account --key-file=/secrets/data-service-account.json
mkdir -p /mnt/gcs_bucket
gcsfuse --key-file=/secrets/data-service-account.json $GCS_BUCKET_NAME /mnt/gcs_data
echo 'GCS bucket mounted at /mnt/gcs_data'
mkdir -p /app/cheese_data
mount --bind /mnt/gcs_data/images /app/cheese_data
"