-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.sh
More file actions
37 lines (28 loc) · 773 Bytes
/
tutorial.sh
File metadata and controls
37 lines (28 loc) · 773 Bytes
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
#!/bin/bash
IMAGE_NAME=openai_tutorial
DOCKER_PATH=./tutorial_env/Dockerfile
build() {
export $(cat .env | xargs)
docker build \
--build-arg OPENAI_API_KEY=$OPENAI_API_KEY \
-t ${IMAGE_NAME} -f ${DOCKER_PATH} .
}
start() {
# Check if container exists
EXISTING_CONTAINER=$(docker ps -a -q --filter "name=${IMAGE_NAME}")
if [ ! -z "$EXISTING_CONTAINER" ]; then
# Remove existing container
docker rm -f ${EXISTING_CONTAINER}
fi
# -i:interactive, -t:tty, --rm:remove container if exit --name:container name
docker run --rm -it --name ${IMAGE_NAME} \
-v ${PWD}/contents:/contents \
${IMAGE_NAME} sh -c "bash"
}
if [[ "$1" == "build" ]]; then
build
elif [[ "$1" == "start" ]]; then
start
else
echo "Invalid option. Use 'build' or 'start'"
fi