docker-compose fixes

This commit is contained in:
2025-12-03 11:34:08 -05:00
parent 4138edf45d
commit 31815d3145

View File

@@ -2,20 +2,18 @@ version: '3.8'
services: services:
# --- 1. Spring API Service (Backend) --- # --- 1. Spring API Service (Backend) ---
spring-api: ss_builder-api:
build: build:
context: ./backend # Path to your Spring project's root folder context: ./backend # Path to your Spring project's root folder
dockerfile: Dockerfile # Assumes you have a Dockerfile in ./backend dockerfile: Dockerfile # Assumes you have a Dockerfile in ./backend
container_name: spring-api container_name: ss_builder-api
ports: ports:
- "8080:8080" # Map host port 8080 to container port 8080 - "8080:8080" # Map host port 8080 to container port 8080
environment: environment:
# These environment variables link the API to the database service defined below # These environment variables link the API to the database service defined below
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/mydatabase - SPRING_DATASOURCE_URL=jdbc:postgresql://r710.dev.gofwd.group:5433/ss_builder
- SPRING_DATASOURCE_USERNAME=myuser - SPRING_DATASOURCE_USERNAME=dba
- SPRING_DATASOURCE_PASSWORD=mypassword - SPRING_DATASOURCE_PASSWORD=!@#Qwerty
depends_on:
- db
networks: networks:
- app-network - app-network
@@ -24,38 +22,20 @@ services:
build: build:
context: ./frontend # Path to your Next.js project's root folder context: ./frontend # Path to your Next.js project's root folder
dockerfile: Dockerfile # Assumes you have a Dockerfile in ./frontend dockerfile: Dockerfile # Assumes you have a Dockerfile in ./frontend
container_name: nextjs-app container_name: ss_builder-app
ports: ports:
- "3000:3000" # Map host port 3000 to container port 3000 - "3000:3000" # Map host port 3000 to container port 3000
environment: environment:
# This variable is crucial: Next.js needs the URL for the Spring API # This variable is crucial: Next.js needs the URL for the Spring API
# Use the Docker internal service name 'spring-api' and its port 8080 # Use the Docker internal service name 'spring-api' and its port 8080
- NEXT_PUBLIC_API_URL=http://spring-api:8080 - NEXT_PUBLIC_API_URL=http://ss_builder-api:8080
# For local testing, you might need the host IP for Next.js to call back # For local testing, you might need the host IP for Next.js to call back
# - NEXT_PUBLIC_API_URL_LOCAL=http://localhost:8080 # - NEXT_PUBLIC_API_URL_LOCAL=http://localhost:8080
depends_on: depends_on:
- spring-api - ss_builder-api
networks: networks:
- app-network - app-network
# --- 3. PostgreSQL Database Service (Example Dependency) ---
db:
image: postgres:15-alpine # Lightweight and stable PostgreSQL image
container_name: postgres-db
environment:
- POSTGRES_DB=mydatabase
- POSTGRES_USER=myuser
- POSTGRES_PASSWORD=mypassword
volumes:
- postgres_data:/var/lib/postgresql/data # Persist the database data
ports:
- "5432:5432" # Optional: Map DB port for external access (e.g., DBeaver)
networks:
- app-network
# --- Docker Volume for Persistent Data ---
volumes:
postgres_data:
# --- Docker Network for Inter-Container Communication --- # --- Docker Network for Inter-Container Communication ---
networks: networks: