Skip to content

Commit

Permalink
0.1.0 add run, run -d, stop
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSchlichting committed Aug 28, 2024
1 parent cbced7f commit b141bd0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Use `jo.sh` in lieu of `virtualenv`, `venv,` `pyenv`, or any of the others; *Pyt
```
Usage: ./jo.sh [COMMAND] [OPTIONS]
Commands:
run: Launch a stateless interactive shell with Python and Poetry installed
--detach, -d: Run the container in the background
stop: Stop the container if running
build: Build the container
--poetry-install: Install the dependencies in the pyproject.toml file into the image
--no-cache: Do not use cached layers of user specific content (poetry packages, Dockerfile commands from /Users/josh/.config/josh/dockerfile_commands)
Expand Down
37 changes: 36 additions & 1 deletion jo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,39 @@ echo "Image and container name (based on \$pwd): $CONTAINER_NAME"
echo Default Docker image: $PYTHON_VERSION
echo "Use '$0 help' for more information"
set -e
if [ "$1" = "build" ]; then
if [ "$1" = "run" ]; then
DETACH_FLAG=""
while [ $# -gt 0 ]; do
case $1 in
--detach|-d)
DETACH_FLAG="-d"
DETACH_DETAILS="-c \"tail -f /dev/null\""
echo "Running in detached mode"
shift
;;
*)
shift
;;
esac
done
if [ -z "$DETACH_FLAG" ]; then
DETACH_FLAG="-it"
fi
docker run \
$DETACH_FLAG \
--entrypoint /bin/bash \
--rm \
--name $CONTAINER_NAME \
--volume $(pwd):/app \
--platform linux/amd64 \
-w /app \
-v $HOME/.aws:/root/.aws \
$CONTAINER_NAME $DETACH_DETAILS

elif [ "$1" = "stop" ]; then
echo Stopping container \"$CONTAINER_NAME\"...
docker container stop $CONTAINER_NAME
elif [ "$1" = "build" ]; then
POETRY_INSTALL=""
POETRY_FILES=""
NO_CACHE=""
Expand Down Expand Up @@ -245,6 +277,9 @@ elif [[ "$1" == *.py ]]; then
elif [[ "$1" == *help ]]; then
echo "Usage: $0 [COMMAND] [OPTIONS]"
echo "Commands:"
echo " run: Launch a stateless interactive shell with Python and Poetry installed"
echo " --detach, -d: Run the container in the background"
echo " stop: Stop the container if running"
echo " build: Build the container"
echo " --poetry-install: Install the dependencies in the pyproject.toml file into the image"
echo " --no-cache: Do not use cached layers of user specific content (poetry packages, Dockerfile commands from $CONFIG_DOCKER_COMMANDS_FILE)"
Expand Down

0 comments on commit b141bd0

Please sign in to comment.