btc_horse/docker/docker-compose.yml

89 lines
3.5 KiB
YAML

# docker-compose.yml
version: '3.8'
# Define the services for our application stack
services:
# PostgreSQL database service
postgres:
# Using the official PostgreSQL base image.
# 'postgres:16' is recommended for a stable, recent version.
# You can use 'postgres:latest' for the very newest, but versions like 13, 14, 15, 16 are common.
image: postgres:16 # Or postgres:latest, postgres:13-alpine, etc.
container_name: postgres_db # Assign a friendly name to the container
environment:
# --- CRITICAL: These settings will ONLY take effect if ./dbData directory is EMPTY on first run ---
POSTGRES_DB: horse # Your database name
POSTGRES_USER: postgres # Set to 'postgres', the default superuser for the official image
POSTGRES_PASSWORD: root # Your desired password for the 'postgres' user
# --------------------------------------------------------------------------------------------------
ports:
- "5434:5432" # Map host port 5434 to container port 5432
volumes:
# Using a bind mount. You MUST delete the ./dbData directory manually if you change user/pass/db.
# This directory MUST be empty when the container first starts to trigger initialization.
- ./dbData:/var/lib/postgresql/data # Persist PostgreSQL data to a local directory
# Added command for more verbose logging during startup (optional, but highly recommended here)
command: postgres -c log_statement=all
networks:
- app_network # Connect to our custom application network
# networks:
# - app_network # Connect to our custom application network
spring:
#image: mathewfrancisv/spring_back_postgres:v1.0.0
image: mathewfrancisv/spring_alpine:v1.0.0
container_name: spring_app
ports:
- "8083:8080"
environment:
# jdbc:postgresql://localhost:5432/horse
# SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/horse
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/horse
SPRING_DATASOURCE_USERNAME: postgres # Ensure this matches POSTGRES_USER
SPRING_DATASOURCE_PASSWORD: root # Ensure this matches POSTGRES_PASSWORD
SPRING_DATASOURCE_CORSIP: http://10.222.236.167:4200
#network_mode: host
volumes:
- ../springHorse:/app
networks:
- app_network
depends_on:
- postgres
# Angular frontend application service
angular-dev:
image: node:20.19.0-alpine
container_name: angular_dev_app
working_dir: /app
volumes:
- ../btc-UI:/app
command: sh -c "npm install && npm run start"
# IMPORTANT: This service is explicitly part of the 'app_network' (bridge)
# Removing network_mode: host for this service
# network_mode: host
ports:
- "4200:4200" # REQUIRED to expose Angular to the host machine in bridge mode
networks:
- app_network # Connect to the custom bridge network
depends_on:
- spring # The 'spring' service might not be directly reachable by name here
# Optional Nginx service for Angular (if you were deploying production build)
# angular:
# image: nginx:alpine
# container_name: angular_app
# ports:
# - "80:80"
# volumes:
# - ./angular/dist/your-angular-app:/usr/share/nginx/html
# - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
# networks:
# - app_network
# depends_on:
# - spring
# Define the custom bridge network for 'angular-dev'
networks:
app_network:
driver: bridge # Use the default bridge driver