Skip to content

Commit 1d45e4e

Browse files
committed
fix(dev): fix attach behavior
1 parent fc0d812 commit 1d45e4e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

enter_dev_env.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash -xe
2-
CONTAINER="${USER}_pycontw_vm"
2+
CONTAINER="pycontw"
33
COMPOSE_FILE="./docker-compose-dev.yml"
44

55
# test if the container is running
@@ -14,15 +14,14 @@ fi
1414

1515
if [ -n "$HASH" ];then
1616
echo "found existing running container $CONTAINER, proceeding to exec another shell"
17-
docker-compose -f $COMPOSE_FILE restart
18-
docker exec -w /app/src -it $HASH bash -c "SHELL=bash poetry shell"
17+
docker-compose -f $COMPOSE_FILE exec -i $CONTAINER bash -c "SHELL=bash source /app/.venv/bin/activate && bash"
1918
elif [ -n "$HASH_STOPPED" ];then
2019
echo "found existing stopped container $CONTAINER, starting"
21-
docker-compose -f $COMPOSE_FILE restart
22-
docker start --attach -i $HASH_STOPPED
20+
(docker-compose -f $COMPOSE_FILE restart && docker start $HASH_STOPPED) >/dev/null 2>&1
21+
docker-compose -f $COMPOSE_FILE exec -i $CONTAINER bash -c "SHELL=bash source /app/.venv/bin/activate && bash"
2322
else
2423
echo "existing container not found, creating a new one, named $CONTAINER"
25-
docker-compose -f $COMPOSE_FILE pull
26-
docker-compose -f $COMPOSE_FILE run -p 8000:8000 --name=$CONTAINER pycontw bash -c "SHELL=bash poetry shell"
24+
docker-compose -f $COMPOSE_FILE up --build --remove-orphans -d
25+
docker-compose -f $COMPOSE_FILE exec -i $CONTAINER bash -c "SHELL=bash source /app/.venv/bin/activate && bash"
2726
fi
2827
echo "see you, use 'docker rm $CONTAINER' to kill the dev container or 'docker-compose -f $COMPOSE_FILE down' to kill both the postgres and the dev container if you want a fresh env next time"

0 commit comments

Comments
 (0)