sndev bash script and docker reliability stuff
This commit is contained in:
parent
0614cfe979
commit
51dba02569
|
@ -34,6 +34,7 @@ envbak
|
|||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.sndev
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
|
|
@ -8,6 +8,5 @@ WORKDIR /app
|
|||
|
||||
EXPOSE 3000
|
||||
|
||||
RUN npm install --loglevel verbose --legacy-peer-deps
|
||||
RUN npx prisma migrate dev
|
||||
CMD npm run dev
|
||||
RUN npm ci --loglevel verbose --legacy-peer-deps
|
||||
CMD npx prisma migrate dev && npm run dev
|
|
@ -4,17 +4,17 @@ services:
|
|||
container_name: db
|
||||
build: ./db
|
||||
restart: always
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U sn -d stackernews"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
expose:
|
||||
- "5432"
|
||||
ports:
|
||||
- "5431:5432"
|
||||
env_file:
|
||||
- ./.env.sndev
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
volumes:
|
||||
- ./anon.sql:/docker-entrypoint-initdb.d/anon.sql
|
||||
- db:/var/lib/postgresql/data
|
||||
|
@ -31,6 +31,10 @@ services:
|
|||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
opensearch:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
env_file:
|
||||
- ./.env.sndev
|
||||
expose:
|
||||
|
@ -49,10 +53,13 @@ services:
|
|||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
app:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
opensearch:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
env_file:
|
||||
- ./.env.sndev
|
||||
ports:
|
||||
|
@ -116,6 +123,11 @@ services:
|
|||
os-dashboard:
|
||||
image: opensearchproject/opensearch-dashboards:latest
|
||||
container_name: os-dashboard
|
||||
restart: always
|
||||
depends_on:
|
||||
opensearch:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
environment:
|
||||
- opensearch.ssl.verificationMode=none
|
||||
- server.ssl.enabled=false
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
sndev__start() {
|
||||
if [ ! -x "$(command -v docker-compose)" ]; then
|
||||
echo "docker compose is not installed"
|
||||
echo "installation instructions are here: https://docs.docker.com/desktop/"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [ -f .env.sndev ]; then
|
||||
echo ".env.sndev does not exist."
|
||||
echo "creating from .env.sample"
|
||||
cp .env.sample .env.sndev
|
||||
fi
|
||||
|
||||
echo "Starting application"
|
||||
docker compose up
|
||||
}
|
||||
|
||||
sndev__stop() {
|
||||
echo "Stopping application"
|
||||
docker compose down
|
||||
}
|
||||
|
||||
sndev__delete() {
|
||||
echo "Deleting application"
|
||||
docker compose down --volumes --remove-orphans
|
||||
}
|
||||
|
||||
sndev__help() {
|
||||
if [ $# -eq 3 ]; then
|
||||
call "sndev__$1__$2__$3" "$@"
|
||||
elif [ $# -eq 2 ]; then
|
||||
call "sndev__$1__$2" "$@"
|
||||
else
|
||||
help="sndev manages a docker based stacker news development environment
|
||||
|
||||
USAGE
|
||||
$ sndev [COMMAND]
|
||||
|
||||
COMMANDS
|
||||
start start env
|
||||
stop stop env
|
||||
delete delete env
|
||||
help display help for sndev
|
||||
"
|
||||
echo "$help"
|
||||
fi
|
||||
}
|
||||
|
||||
call() {
|
||||
func=$1
|
||||
if type "$func" 1>/dev/null 2>&1; then
|
||||
shift
|
||||
"$func" "$@" # invoke our named function w/ all remaining arguments
|
||||
else
|
||||
sndev__help
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
call "sndev__$1" "$@"
|
Loading…
Reference in New Issue