Anthony Truchet commited on
Commit
265f723
·
1 Parent(s): 34227d8

fix: issues with env var and scripts

Browse files
Dockerfile CHANGED
@@ -92,5 +92,5 @@ ENV PYTHONPATH=$APP_CODE:$PYTHONPATH
92
  # Expose streamlit application
93
  EXPOSE 8501
94
  EXPOSE 7860
95
- ENTRYPOINT [bash]
96
- CMD [start_server.sh]
 
92
  # Expose streamlit application
93
  EXPOSE 8501
94
  EXPOSE 7860
95
+ ENTRYPOINT [ "bash", "-o", "allexport" ]
96
+ CMD [ "start_server.sh" ]
on_startup.sh CHANGED
File without changes
scripts/build-local-docker.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ source $(dirname $0)/common_header.sh
3
+
4
+ # Export the dependencies managed by Poetry in the requirements.txt format for pip
5
+ poetry export -f requirements.txt -o requirements.txt --without-hashes --with=jupyter
6
+
7
+ # Re-build the docker image.
8
+ docker build -f $ROOT_DIRECTORY/Dockerfile --label tests -t $CONTAINER_NAME .
9
+
10
+
11
+
scripts/common_header.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ CONTAINER_NAME=persistent-docker-space
2
+ VOLUME_NAME=ai-playground-vol
3
+
4
+ set -e # Exits on first error
5
+
6
+ SCRIPT_PATH="$(realpath "${BASH_SOURCE:-$0}")"
7
+ ROOT_DIRECTORY="$(dirname "$(dirname "${SCRIPT_PATH}")")"
scripts/{build-run-local-docker.sh → run-local-docker.sh} RENAMED
@@ -1,30 +1,15 @@
1
- #!/usr/bin/env sh
2
- CONTAINER_NAME=persistent-docker-space
3
- VOLUME_NAME=ai-playground-vol
4
-
5
- set -e # Exits on first error
6
-
7
- SCRIPT_PATH="$(realpath "${BASH_SOURCE:-$0}")"
8
- ROOT_DIRECTORY="$(dirname "$(dirname "${SCRIPT_PATH}")")"
9
- pushd $ROOT_DIRECTORY
10
- echo "Running from ROOT_DIRECTORY: ${ROOT_DIRECTORY}"
11
-
12
- # Export the dependencies managed by Poetry in the requirements.txt format for pip
13
- poetry export -f requirements.txt -o requirements.txt --without-hashes --with=jupyter
14
-
15
- # Re-build the docker image.
16
- docker build --label tests -t $CONTAINER_NAME .
17
 
18
  # During development ONLY use a `bind mount` to enable
19
  # editing the code without having to rebuild the container.
20
  docker run --rm -it \
21
  -p 8501:8501 -p 7860:7860 \
22
- --env .env \
23
  --mount type=volume,src=$VOLUME_NAME,dst=/data \
24
  --mount type=bind,source=${ROOT_DIRECTORY}/src/,target=/app/,readonly \
25
  --mount type=bind,source=${ROOT_DIRECTORY}/.streamlit,target=/user/.streamlit,readonly \
26
  $CONTAINER_NAME:latest \
27
  $@ # Pass all command line argument quoted in a good way
28
 
29
- popd > /dev/null
30
 
 
1
+ #!/usr/bin/env bash
2
+ source $(dirname $0)/common_header.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # During development ONLY use a `bind mount` to enable
5
  # editing the code without having to rebuild the container.
6
  docker run --rm -it \
7
  -p 8501:8501 -p 7860:7860 \
8
+ --env-file ${ROOT_DIRECTORY}/.env \
9
  --mount type=volume,src=$VOLUME_NAME,dst=/data \
10
  --mount type=bind,source=${ROOT_DIRECTORY}/src/,target=/app/,readonly \
11
  --mount type=bind,source=${ROOT_DIRECTORY}/.streamlit,target=/user/.streamlit,readonly \
12
  $CONTAINER_NAME:latest \
13
  $@ # Pass all command line argument quoted in a good way
14
 
 
15
 
start_jupyter.sh CHANGED
@@ -1,6 +1,8 @@
1
  #!/bin/bash
2
  set -e
3
 
 
 
4
  jupyter lab \
5
  --ip "0.0.0.0" \
6
  --port 7860 \
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ if [ -z ${JUPYTER_TOKEN+x} ]; then echo "Please export JUPYTER_TOKEN from your '.env' file"; exit -2 ; fi
5
+
6
  jupyter lab \
7
  --ip "0.0.0.0" \
8
  --port 7860 \
start_server.sh CHANGED
@@ -1,3 +1,3 @@
1
  #!/bin/bash
2
 
3
- source start_jupyter.sh
 
1
  #!/bin/bash
2
 
3
+ source ./start_jupyter.sh
start_streamlit.sh CHANGED
File without changes