-
Notifications
You must be signed in to change notification settings - Fork 0
1. Setup & Installation
This guide will help you set up YAR using Docker Compose. Follow the steps below to get everything up and running.
Before you begin, ensure you have the following installed on your system:
Create a directory where we will store our files.
mkdir yar && cd yarIn the folder you just created, create a new file named docker-compose.yml and add the following content:
services:
traefik:
image: traefik:v2.2
restart: unless-stopped
command:
- "--api.insecure=true"
- "--api.dashboard=false"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
ports:
- "${EXTERNAL_PORT}:80"
networks:
- yar-network
volumes:
- /var/run/docker.sock:/var/run/docker.sock
database:
image: mariadb
restart: unless-stopped
env_file:
- .env
networks:
- yar-network
volumes:
- yar-database:/var/lib/mysql
healthcheck:
test:
[
"CMD",
"/usr/local/bin/healthcheck.sh",
"--su-mysql",
"--connect",
"--innodb_initialized"
]
backend:
image: borisnl/yar-backend:latest
restart: unless-stopped
env_file:
- .env
depends_on:
database:
condition: service_healthy
networks:
- yar-network
volumes:
- ./data:/app/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=PathPrefix(`/api`)"
- "traefik.http.routers.backend.entrypoints=web"
- "traefik.http.routers.backend.middlewares=strip-api-prefix"
- "traefik.http.middlewares.strip-api-prefix.stripprefix.prefixes=/api"
- "traefik.http.services.backend.loadbalancer.server.port=3000"
web:
image: borisnl/yar-web:latest
restart: unless-stopped
env_file:
- .env
depends_on:
- backend
networks:
- yar-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.web.rule=PathPrefix(`/`)"
- "traefik.http.routers.web.entrypoints=web"
- "traefik.http.services.web.loadbalancer.server.port=3000"
volumes:
yar-database:
networks:
yar-network:Next, create a .env file. This file will hold the environment variables required for YAR. Add the necessary configurations as shown below:
NODE_ENV=production
MYSQL_DATABASE=yar
MARIADB_ROOT_PASSWORD=password
DATABASE_URL=mysql://root:${MARIADB_ROOT_PASSWORD}@database/yar
EXTERNAL_PORT=8080
# The domain where the app is running, this only affects production
DOMAIN=http://localhost:${EXTERNAL_PORT}I strongly recommend changing the root password to a long and secure string.
With the docker-compose.yml and .env files in place, you can now start the application using Docker Compose. Run the following command in your terminal:
docker-compose up -dYour YAR application should now be up and running. You can access it via your web browser at http://localhost:port (replace port with the port number defined in your .env file).
If you encounter any issues during setup, consider the following steps:
- Check the .env file for any missing or incorrect values.
- Review the logs using docker-compose logs for error messages.
- Ensure Docker and Docker Compose are correctly installed and running.