Update README.md instructions. Clean up docker composee & add .env for docker compose file.

This commit is contained in:
2025-02-28 14:34:26 -06:00
parent 6f336b18d3
commit 94a7880db3
5 changed files with 73 additions and 16 deletions

3
docker/.env.example Normal file
View File

@ -0,0 +1,3 @@
PORT=5000
DOMAIN=bang.mydomain.com
NETWORK=bridge

View File

@ -1,23 +1,23 @@
version: '3.8'
services:
bang-web-server:
env_file:
- .env
build:
context: ../ # point to the parent directory where package.json and source code reside
dockerfile: docker/Dockerfile # specific path to the Dockerfile
context: ../
dockerfile: docker/Dockerfile
container_name: bang
domainname: bang.gbrown.org
hostname: bang
domainname: ${DOMAIN}
networks:
- node_apps
- ${NETWORK}
hostname: bang
ports:
- "5000:5000"
- ${PORT}:${PORT}
tty: true
restart: unless-stopped
volumes:
- ../:/app # mount the parent directory to /app in the container
- ../:/app
command: serve -s /app/dist -l 5000
networks:
node_apps:
${NETWORK}:
external: true

52
docker/update-bang Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
# Function to check if we're in the correct directory
check_directory() {
if [ -d "docker" ] && [ -f "package.json" ]; then
return 0 # We're in the root directory
fi
return 1
}
# Initialize root_dir
root_dir=""
# Check if argument is provided
if [ $# -eq 1 ]; then
# Use provided path
if [ -d "$1" ]; then
root_dir="$1"
cd "$root_dir" || exit 1
else
echo "Error: Provided directory does not exist"
exit 1
fi
else
# No argument provided, try to determine location
current_dir=$(basename "$(pwd)")
if [ "$current_dir" = "docker" ]; then
cd .. || exit 1
elif [ "$current_dir" != "Bang" ]; then
echo "Error: Not in the correct directory and no valid path provided"
echo "Please either:"
echo "1. Run this script from the Bang root directory"
echo "2. Run this script from the docker directory"
echo "3. Provide the path to the Bang root directory as an argument"
exit 1
fi
fi
# Verify we're in the correct directory
if ! check_directory; then
echo "Error: Not in the correct directory structure"
echo "Make sure you're in a directory with 'docker' folder and package.json"
exit 1
fi
git pull
pnpm build
cd docker || exit 1
sudo docker compose down
sudo docker compose up -d
cd ..