start_project.sh 633 Bytes
Newer Older
1
2
#!/usr/bin/env bash

3
set -eE
4
5
6
7
8
9
10
11
12
13
14
15
16

readonly IMAGE_TAG=umich_django_template
readonly CONTAINER_NAME=$IMAGE_TAG
readonly CONTAINER_PROJECT_DIR=/usr/src/"$2"

clean_up() {
    docker stop $CONTAINER_NAME
}

if [ "$#" -ne 2 ]; then
  echo "Usage: $1 Project Output Path; $2 Project Name" >&2
  exit 1
fi
Jon Yu's avatar
Jon Yu committed
17

18
19
20
21
22
23
24
if ! [ -d "$1" ]; then
  echo "$1 not a directory" >&2
  exit 1
fi

trap clean_up EXIT

Jon Yu's avatar
Jon Yu committed
25
docker build -t $IMAGE_TAG ./app
26
27
docker run --rm -d -t -v "$1":"$CONTAINER_PROJECT_DIR":z --name $CONTAINER_NAME --entrypoint /bin/bash $IMAGE_TAG
docker exec -it $CONTAINER_NAME django-admin startproject --template ./ "$2" "$CONTAINER_PROJECT_DIR"