# Run Leemons using Docker Compose In order to run Leemons using Docker compose, you need to have Docker and Docker compose installed. If you already have `Docker compose` installed on your machine, please skip the following sections and jump to the final section [3. Running Leemons](#3-Running-Leemons). ## 1. Installing Docker ### For Windows and MacOS users - Download and install Docker Desktop for Windows from the official website - https://www.docker.com/products/docker-desktop - Once installed, run `Docker Desktop`. - Docker should now be running on your system. ### For Linux users - Install the latest version of Docker Engine from the official website - https://docs.docker.com/engine/install/ - Follow the instructions for your specific distribution. - Once installed, run the following command to start Docker: ```sh sudo systemctl start docker ``` ## 2. Installing Docker Compose ### For Windows and MacOS users Docker Compose should already be included in Docker Desktop for Windows, so you don't need to install it separately. To verify that Docker Compose is installed, run the following command in a terminal window: ```sh docker compose version ``` ### For Linux users To install Docker Compose, run the following command in a terminal window: ```sh sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ``` Note: replace the version number 1.29.2 with the latest stable release available on Docker's GitHub repository. Once the installation is complete, run the following command to make sure that Docker Compose is executable: ```sh sudo chmod +x /usr/local/bin/docker-compose ``` To verify that Docker Compose is installed, run the following command in a terminal window: ```sh docker-compose version ``` ## 3. Running Leemons The Leemons docker compose includes all the dependencies needed to run it: - Frontend App - Backend App - MySQL Database - Mongo Database - Redis Data store First, create an empty folder to store your Leemons data. For the purpose of these instructions, we will use the folder name `leemons-docker`: ```sh mkdir leemons-docker cd leemons-docker ``` Second, inside the `leemons-docker` folder, create an `.env` file to store the environment variables that will be passed to Docker Compose on launch, and write the following variables: ```sh # APP ·················· CORS=true # MYSQL ·················· DATABASE_DATABASE=leemons DATABASE_USERNAME=root DATABASE_PASSWORD=leemons USE_CUSTOM_ROLLBACK=true # MONGODB ·················· NOSQL_AUTH_DATABASE=admin NOSQL_DATABASE=leemons NOSQL_USERNAME=root NOSQL_PASSWORD=leemons NOSQL_SRV= # REDIS ·················· REDIS_DB_NAME=leemons REDIS_DB_INDEX=1 ``` Third, inside the `leemons-docker` folder, create a file named `docker-compose.yml`, and write this on it: ```yml version: "3.8" services: mysqldb: image: mysql:5.7 env_file: ./.env command: --default-authentication-plugin=mysql_native_password cap_add: - SYS_NICE restart: always environment: - MYSQL_ROOT_PASSWORD=$DATABASE_PASSWORD - MYSQL_DATABASE=$DATABASE_DATABASE networks: - leemons-db expose: - 3306 volumes: - ./data/mysql:/var/lib/mysql healthcheck: test: mysqladmin ping -h 127.0.0.1 -uroot --password=$$MYSQL_ROOT_PASSWORD timeout: 10s retries: 10 mongo: image: mongo:4.2.0 env_file: ./.env restart: always environment: MONGO_INITDB_ROOT_USERNAME: $NOSQL_USERNAME MONGO_INITDB_ROOT_PASSWORD: $NOSQL_PASSWORD volumes: - ./data:/data/db networks: - leemons-db expose: - 27017 redis: image: redis:6.2.7 container_name: redis restart: unless-stopped command: "redis-server --notify-keyspace-events Ex" expose: - 6379 volumes: - ./data/redis:/data networks: - leemons-db frontend: image: leemonade/leemons-front:dev restart: unless-stopped stdin_open: true tty: true ports: - 3000:3000 environment: - API_URL=http://localhost:8080 networks: - leemons-app backend: image: leemonade/leemons-back:dev env_file: ./.env restart: unless-stopped stdin_open: true tty: true ports: - 8080:8080 environment: - DATABASE_HOST=mysqldb - DATABASE_PORT=3306 - NOSQL_HOST=mongo - NOSQL_PORT=27017 - REDIS_HOST=redis - REDIS_PORT=6379 networks: - leemons-app - leemons-db depends_on: mongo: condition: service_started mysqldb: condition: service_healthy networks: leemons-app: leemons-db: ``` Finally, inside the `leemons-docker` folder, launch Leemons using: - Windows and MacOS users: ```sh docker compose up -d ``` - Linux users ```sh docker-compose up -d ``` After a couple of minutes, you will be able to enjoy Leemons in your browser at http://localhost:3000 > ### IMPORTANT > Leemons runs on ports `3000` and `8080`, so before launching it for the first time, please check the availability of those ports. ## Troubleshooting - Apple M1: Some of the Docker images used in this `docker-compose` file, are not available in `linux/amd64` release list, if you are using M1 processors, you may don't be able tu run Leemons. - I don't see anything at http://localhost:3000: Probably some Docker image or some configuration did not come out correctly. Please, inside the `leemons-docker` folder, run `docker compose logs` and tell us what it shows.