Commit 56525207 authored by Jon Yu's avatar Jon Yu
Browse files

Tweak start_project so it copies, substitutes properly

parent 119ae227
Pipeline #17408 passed with stage
in 14 seconds
#!/usr/bin/env bash #!/usr/bin/env bash
set -eE readonly OUTPUT_PATH="$1"
readonly PROJECT_NAME="$2"
readonly IMAGE_TAG=umich_django_template readonly IMAGE_TAG="python:slim"
readonly CONTAINER_NAME=$IMAGE_TAG readonly CONTAINER_NAME="umich_template_project_runner"
readonly CONTAINER_PROJECT_DIR=/usr/src/"$2" readonly CONTAINER_OUTPUT_DIR=/usr/src/$PROJECT_NAME
clean_up() { clean_up() {
docker stop $CONTAINER_NAME docker stop $CONTAINER_NAME >/dev/null
} }
if [ "$#" -ne 2 ]; then if [ "$#" -ne 2 ]; then
echo "Usage: $1 Project Output Path; $2 Project Name" >&2 echo "Usage: start_project [Output Path] [Project Name]" >&2
exit 1 exit 1
fi fi
if ! [ -d "$1" ]; then if ! [ -d "$OUTPUT_PATH" ]; then
echo "$1 not a directory" >&2 echo "$OUTPUT_PATH not a directory" >&2
exit 1 exit 1
fi fi
trap clean_up EXIT trap clean_up EXIT
docker build -t $IMAGE_TAG ./app set -eE
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" docker run --rm -d -t -v "$OUTPUT_PATH":"$CONTAINER_OUTPUT_DIR":z -v "$(pwd)":"$CONTAINER_BASE_TEMPLATE_DIR":ro --name $CONTAINER_NAME --entrypoint /bin/bash $IMAGE_TAG
\ No newline at end of file docker exec -t $CONTAINER_NAME python -m pip install django
docker exec -t $CONTAINER_NAME django-admin startproject --template=$CONTAINER_BASE_TEMPLATE_DIR --name=Dockerfile "$PROJECT_NAME" "$CONTAINER_OUTPUT_DIR"
echo "Done! Change dir to $OUTPUT_PATH and run docker-compose up --build to start the project"
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment