version: '3'
services:
 # Client container
  client:
    build:
      context: frontend
      dockerfile: Dockerfile
    container_name: client
    ports:
      - "3000:3000"
    volumes:
      - ./frontend:/var/www/frontend

  #Laravel App
  app:
    build:
      context: backend
      dockerfile: Dockerfile
    image: hakase-labs/laravel
    container_name: app
    restart: unless-stopped
    tty: true
    ports:
      - "9000:9000"
    environment:
      SERVICE_NAME: app
      SERVICE_TAGS: dev
    working_dir: /var/www/backend
    volumes:
      - ./backend/php/local.ini:/usr/local/etc/php/conf.d/local.ini
      - ./backend:/var/www/backend
    depends_on:
      - db

  #SSL
  certbot:
    image: certbot/certbot:latest
    container_name: certbot
    volumes:
      - ./certbot/www/:/var/www/certbot/:rw
      - ./certbot/conf/:/etc/letsencrypt/:rw

  #Nginx Service
  nginx:
    image: nginx:alpine
    container_name: nginx
    restart: unless-stopped
    tty: true
    ports:
      # Nuxt port
      - "80:80"
      # Laravel port
      - "81:81"
      - "443:443"
    volumes:
      - ./:/var/www
      - ./certbot/www:/var/www/certbot/:ro
      - ./certbot/conf:/etc/letsencrypt/:ro
      - ./nginx/config/default.conf:/etc/nginx/conf.d/default.conf
      - ./nginx/config/nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - app
      - client

  #MySQL Service
  db:
    image: mysql:5.7
    container_name: db
    restart: unless-stopped
    tty: true
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: shopdb
      MYSQL_USER: xxx
      MYSQL_PASSWORD: xxx
      MYSQL_ROOT_PASSWORD: xxx
    volumes:
      - mysqldata:/var/lib/mysql/
#Docker Networks
# networks:
  # mynet:
    # driver: bridge
#Volumes
volumes:
  mysqldata:
    driver: local