version: '3.8'

services:
  strapi:
    image: strapi/strapi:latest
    container_name: strapi-app
    restart: unless-stopped
    env_file: .env
    environment:
      DATABASE_CLIENT: mysql
      DATABASE_HOST: mysql
      DATABASE_PORT: 3307
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      JWT_SECRET: ${JWT_SECRET}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      API_TOKEN_SALT: ${API_TOKEN_SALT}
      APP_KEYS: ${APP_KEYS}
      NODE_ENV: ${NODE_ENV}
    volumes:
      - ./app:/opt/app
      - ./uploads:/opt/app/public/uploads
    ports:
      - '1337:1337'
    depends_on:
      - mysql
    networks:
      - strapi-network

  mysql:
    image: mysql:8.0
    container_name: strapi-mysql
    restart: unless-stopped
    env_file: .env
    environment:
      MYSQL_DATABASE: ${DATABASE_NAME}
      MYSQL_USER: ${DATABASE_USERNAME}
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD}
    volumes:
      - mysql-data:/var/lib/mysql
    ports:
      - '3307:3307'
    networks:
      - strapi-network

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: strapi-phpmyadmin
    restart: unless-stopped
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3307
      PMA_USER: ${DATABASE_USERNAME}
      PMA_PASSWORD: ${DATABASE_PASSWORD}
    ports:
      - '8080:80'
    depends_on:
      - mysql
    networks:
      - strapi-network

volumes:
  mysql-data:

networks:
  strapi-network:
    driver: bridge
