version: '3.8'

services:
  mysql:
    image: mysql:8
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: Repo1423@ 
      MYSQL_DATABASE: zstech_n8n
      MYSQL_USER: zstech_n8n
      MYSQL_PASSWORD: 7ND50qXoFo3y 
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      timeout: 20s
      retries: 10

  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "${N8N_PORT}:5678"
    environment:
      - DB_TYPE=${DB_TYPE}
      - DB_MYSQLDB_HOST=${DB_MYSQLDB_HOST}
      - DB_MYSQLDB_PORT=${DB_MYSQLDB_PORT}
      - DB_MYSQLDB_DATABASE=${DB_MYSQLDB_DATABASE}
      - DB_MYSQLDB_USER=${DB_MYSQLDB_USER}
      - DB_MYSQLDB_PASSWORD=${DB_MYSQLDB_PASSWORD}
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - N8N_BASIC_AUTH_ACTIVE=${N8N_BASIC_AUTH_ACTIVE}
      - N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
    depends_on:
      mysql:
        condition: service_healthy
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
  mysql_data:

