feat: update Docker Compose configuration and add deployment script

This commit is contained in:
Nils-Johan Gynther
2026-04-15 20:06:20 +02:00
parent 8efd9f6e1e
commit 29d4cef688
3 changed files with 45 additions and 3 deletions
+12
View File
@@ -0,0 +1,12 @@
# Kopiera till .env och fyll i riktiga värden
# cp .env.example .env
# MariaDB
MARIADB_ROOT_PASSWORD=byt-ut-mig
MARIADB_DATABASE=recipe_app
MARIADB_USER=recipe_user
MARIADB_PASSWORD=byt-ut-mig
# Publik URL (används av frontend)
NEXT_PUBLIC_APP_URL=https://recept.gynther.se
NEXT_PUBLIC_API_URL=https://api.recept.gynther.se
+9 -3
View File
@@ -4,10 +4,15 @@ services:
context: ./frontend
dockerfile: Dockerfile
image: recipe-frontend:local
pull_policy: never
container_name: recipe-frontend
restart: unless-stopped
environment:
NEXT_PUBLIC_API_URL: "http://recipe-api:8080"
NODE_ENV: "production"
HOSTNAME: "0.0.0.0"
PORT: "3000"
NEXT_PUBLIC_APP_URL: "${NEXT_PUBLIC_APP_URL}"
NEXT_PUBLIC_API_URL: "${NEXT_PUBLIC_API_URL}"
NEXT_PUBLIC_API_URL_INTERNAL: "http://recipe-api:8080"
volumes:
- recipe_images:/app/public/images
depends_on:
@@ -28,9 +33,10 @@ services:
context: ./backend
dockerfile: Dockerfile
image: recipe-api:local
pull_policy: never
container_name: recipe-api
restart: unless-stopped
environment:
NODE_ENV: "production"
DATABASE_URL: "mysql://root:${MARIADB_ROOT_PASSWORD}@recipe-db:3306/${MARIADB_DATABASE}"
volumes:
- recipe_images:/app/recipe-images
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
# deploy.sh Bygg och starta om recipe-app
# Kör från: /opt/containers/recipe-app/
# Kräver: .env-fil i samma mapp
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
if [ ! -f ".env" ]; then
echo "Fel: .env saknas. Kopiera .env.example och fyll i värdena:"
echo " cp .env.example .env && nano .env"
exit 1
fi
echo "Bygger images..."
docker compose build
echo "Startar tjänster..."
docker compose up -d
echo "Status:"
docker compose ps