version: "3"
services:
  nextjs-app: # https://sofia.mwhitnessing.com/
    hostname: jwpw-app-staging # jwpw-nextjs-app-1
    image: docker.d-popov.com/jwpw:latest
    volumes:
      - /mnt/docker_volumes/pw-demo/app/public/content/uploads/:/app/public/content/uploads
      - /mnt/docker_volumes/pw-demo/app/logs:/app/logs
    environment:
      - APP_ENV=test
      - NODE_ENV=test
      - TZ=Europe/Sofia
      - DATABASE=mysql://jwpwsofia_demo:dwxhns9p9vp248@mariadb-demo:3306/jwpwsofia_demo
      - UPDATE_CODE_FROM_GIT=true # Set to true to pull latest code from Git
      - GIT_BRANCH=main
      - GIT_USERNAME=deploy
      - GIT_PASSWORD=L3Kr2R438u4F7
      - ADMIN_PASSWORD=kolichkisofia2024
    command: >
      sh -c "
        cd /app && 
        rm -rf node_modules package-lock.json && 
        npm install --no-package-lock && 
        npm uninstall @prisma/client prisma && 
        npm install @prisma/client@5.22.0 prisma@5.22.0 --save-exact && 
        npx next build && 
        npx prisma migrate deploy && 
        npx prisma generate && 
        npm run start-env; 
        tail -f /dev/null"
    tty: true
    stdin_open: true
    restart: always
    networks:
      - infrastructure_default
      - default
  mariadb:
    deploy:
      replicas: 1
    hostname: mariadb-demo
    image: mysql:latest #mariadb:10.4
    volumes:
      - /mnt/docker_volumes/pw-demo2/data/mysql:/var/lib/mysql
    environment:
      MARIADB_ROOT_PASSWORD: i4966cWBtP3xJ7BLsbsgo93
      MYSQL_ROOT_PASSWORD: i4966cWBtP3xJ7BLsbsgo93
      MYSQL_DATABASE: jwpwsofia_demo
      MYSQL_USER: jwpwsofia_demo
      MYSQL_PASSWORD: dwxhns9p9vp248
  adminer:
    image: adminer
    restart: always
    ports:
      - 5002:8080
networks:
  infrastructure_default:
    external: true
