build: single dev. deployment shellscript
This commit is contained in:
parent
d73d15f3c3
commit
06a2353153
@ -45,7 +45,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
qnote:
|
qnote:
|
||||||
external: false
|
external: false
|
||||||
name: qnote
|
name: server_qnote
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
qnote-data:
|
qnote-data:
|
@ -61,4 +61,4 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
qnote:
|
qnote:
|
||||||
external: false
|
external: false
|
||||||
name: qnote
|
name: full_qnote
|
@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Delete all Docker artifacts (e.g. DB) from previous test runs
|
|
||||||
|
|
||||||
docker stop qnote-server qnote-psql && docker rm -f qnote-server qnote-psql
|
|
||||||
docker volume rm -f qnote-data
|
|
||||||
[ -d "data" ] && sudo rm -rf data
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
DEV_COMPOSE_FILE="docker-compose-dev-backend.yml"
|
|
||||||
|
|
||||||
[ "$( docker container inspect -f '{{.State.Status}}' qnote-psql )" = "running" ] || docker compose up qnote-psql -d
|
|
||||||
|
|
||||||
# Shutdown, rebuild, & restart
|
|
||||||
docker compose stop qnote-server && docker compose rm -f qnote-server
|
|
||||||
docker compose -f $DEV_COMPOSE_FILE build
|
|
||||||
docker compose -f $DEV_COMPOSE_FILE up qnote-server
|
|
79
scripts/run_dev.sh
Executable file
79
scripts/run_dev.sh
Executable file
@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
echo "[?] usage: $0 [-h|-f|-p]"
|
||||||
|
echo -e "\t-f run both frontend and backend (default: false)"
|
||||||
|
echo -e "\t-p purge any existing database artifacts (default: false)"
|
||||||
|
echo -e "\t-q only purge old data without building/spawning any new containers (default: false)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default to running the backend only without destroying old data from previous runs
|
||||||
|
RUN_FULLSTACK=false
|
||||||
|
PURGE_ARTIFACTS=false
|
||||||
|
|
||||||
|
# Optionally only purge the existing data without running any new containers
|
||||||
|
PURGE_ONLY=false
|
||||||
|
|
||||||
|
BACKEND_COMPOSE_FILE="docker/docker-compose-back.yml"
|
||||||
|
FULL_COMPOSE_FILE="docker/docker-compose-full.yml"
|
||||||
|
|
||||||
|
# Ensure we're at project root and the compose files exist
|
||||||
|
[ -f ".env" ] || { echo "[!] run the script from project root" && exit 1; }
|
||||||
|
[ -f "$BACKEND_COMPOSE_FILE" ] || { echo "[!] backend compose file missing" && exit 1; }
|
||||||
|
[ -f "$FULL_COMPOSE_FILE" ] || { echo "[!] fullstack compose file missing" && exit 1; }
|
||||||
|
|
||||||
|
while getopts "hfpq" OPTION;
|
||||||
|
do
|
||||||
|
case "$OPTION" in
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
f)
|
||||||
|
RUN_FULLSTACK=true
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
PURGE_ARTIFACTS=true
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
PURGE_ARTIFACTS=true
|
||||||
|
PURGE_ONLY=true
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$PURGE_ARTIFACTS" = true ]
|
||||||
|
then
|
||||||
|
echo "[+] purging old database artifacts"
|
||||||
|
docker stop qnote-psql
|
||||||
|
docker rm -f qnote-psql
|
||||||
|
docker volume rm -f qnote-data # Backend mode
|
||||||
|
[ -d "data" ] && sudo rm -rf data # Fullstack mode
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PURGE_ONLY" = true ]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$( docker container inspect -f '{{.State.Status}}' qnote-psql )" = "running" ] || docker compose up qnote-psql -d &>/dev/null
|
||||||
|
|
||||||
|
# Shutdown, rebuild, and restart relevant containers
|
||||||
|
if [ "$RUN_FULLSTACK" = true ]
|
||||||
|
then
|
||||||
|
echo "[+] running in fullstack mode"
|
||||||
|
docker compose stop qnote-server qnote-web
|
||||||
|
docker compose rm -f qnote-server qnote-web
|
||||||
|
docker compose --env-file .env -f "$FULL_COMPOSE_FILE" build
|
||||||
|
docker compose --env-file .env -f "$FULL_COMPOSE_FILE" up qnote-server qnote-web
|
||||||
|
else
|
||||||
|
echo "[+] running in backend mode"
|
||||||
|
docker compose stop qnote-server
|
||||||
|
docker compose rm -f qnote-server
|
||||||
|
docker compose --env-file .env -f "$BACKEND_COMPOSE_FILE" build
|
||||||
|
docker compose --env-file .env -f "$BACKEND_COMPOSE_FILE" up qnote-server
|
||||||
|
fi
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
DEV_COMPOSE_FILE="docker-compose.yml"
|
|
||||||
|
|
||||||
[ "$( docker container inspect -f '{{.State.Status}}' qnote-psql )" = "running" ] || docker compose up qnote-psql -d
|
|
||||||
|
|
||||||
# Shutdown, rebuild, & restart
|
|
||||||
docker compose stop qnote-server qnote-web && docker compose rm -f qnote-server qnote-web
|
|
||||||
docker compose -f $DEV_COMPOSE_FILE build
|
|
||||||
docker compose -f $DEV_COMPOSE_FILE up qnote-server qnote-web
|
|
Loading…
x
Reference in New Issue
Block a user