Make sure you've done npm i at the root of the repo. This will run dev-tools/setup.sh.
You may need to restart your shell, or do . ~/.profile to ensure everything is in your path.
Alternatively, you can install dev-tools without cloning the repo by doing:
curl "https://raw.githubusercontent.com/AudiusProject/apps/main/dev-tools/setup.sh" | bashMake sure Docker is running and do:
npm run protocol
You can use audius-compose ps to ensure that all services report "Status" as Healthy.
All options passed to
npm run protocolwill be passed toaudius-composeunder the hood.
You can also do
audius-compose updirectly, but this has the disadvantage of not building the required Javascript dependencies before bringing up the protocol. See CLI Tools for details
To use the client from a mac, we need to route hostnames to the audius-compose nginx reverse proxy by running:
audius-compose connect
Use these CLI tools for Audius dev. Currently there are 3 tools available:
audius-compose: start, stop, and manage Audius service containersaudius-cmd: perform user actions, e.g.create-user,upload-track,repost-playlist
View all available commands for any of these tools with --help, e.g.
> audius-compose --help
> audius-cmd --helpYou can confirm that things are wired up correctly by running audius-cmd create-user.
Note that audius-cmd requires the stack to be up and healthy, per Bring up the protocol, and to have run audius-compose connect.
The audius-cmd script in this directory will build the audius-cmd tool if it detects
the output is missing. Otherwise, you can force a build by running audius-cmd build
Examples of available commands can be found here
Periodically prune docker cache
audius-compose prune
Get service logs
audius-compose logs discovery-provider-1 # get name from `docker ps`
Set environment variables
audius-compose set-env discovery-provider-1 audius_discprov_url https://discoveryprovider.testing.com/
Load environment variables
audius-compose load-env discovery-provider prod
Increase docker resource allocations to avoid OOM kills and your local docker image repository running out of space.
Below are suggested minimum values:
Docker > Preferences > Resources > Advanced
- CPUs 4
- Memory 13 GB
- Disk Image Size 120 GBIf you still run into issues, you may execute a docker system prune to free additional space.
- The audius-compose Python script in this directory handles all
audius-composecommand logic and subcommands. Any changes you make there will be reflected automatically - no reinstallation needed audius-compose upis a wrapper for creating the top-level .env file (see thegenerate_env()function in theaudius-composePython script) and then runningdocker compose upwith various services passed as args
- Every Docker service is defined in one of the root-level .yml files (e.g.,
docker-compose.discovery.prod.ymlfor services related to Discovery Node), and then it's imported intodocker-compose.ymlusing extends syntax- This pattern prevents the top-level
docker-compose.ymlfile from growing too large and allows every service to have standardized logging,extra_hosts(allows the containers to talk to each other), and memory limits (makesdocker statsmore readable) by using the<<: *commonproperty. This property is YAML's "merge key" syntax which essentially adds every field from thecommonvariable defined at the top of the file docker-compose.test.ymlalso importsdocker-compose.ymlservices for building images and testing in CI
- This pattern prevents the top-level
audius-compose connectallows you to access containers via hostname by appending hostnames to your/etc/hosts(one-time operation unless you change container names or add a new service)- This
/etc/hostschange tells your browser (or CURL, or whatever) to go to127.0.0.1 - The
ingresscontainer listens on127.0.0.1for port 80 and redirects every request to the desired container based on hostname- For example, if you request
audius-discovery-provider-1/health_check, theingresscontainer sees the hostname asaudius-discovery-provider-1and directs it to the Discovery Node's container and port. This removes the need for you as the dev (or any application code except ingress) to ever worry about port numbers
- For example, if you request
- The
extra_hostsconfig that gets added to every service indocker-compose.ymlis what allows this to happen from within containers. For example, theextra_hostsline that says- "audius-discovery-provider-1:host-gateway"tells every container, "When you see the hostname "audius-discovery-provider-1", resolve it using the machine's (not the container's) localhost (i.e., "host-gateway"). Your machine's localhost knows to direct "audius-discovery-provider-1" to 127.0.0.1:80 (thanks toaudius-compose connect), where the nginxingresscontainer will be listening and will direct the request to the Discovery Node container
- Configure the service in its own .yml file, either using an existing one (e.g., use
docker-compose.discovery.prod.ymlif it's a Discovery-related service) or by creating a new one- The typical pattern here is to have a
Dockerfilein the service's directory, and then when configuring the service (e.g., in top-leveldocker-compose.discovery.prod.yml) use:service-name: build: context: <service_directory containing Dockerfile (e.g., discovery-provider)>
- The typical pattern here is to have a
- Add that service to the top-level
docker-compose.ymlfile using the extends syntax, and then add<<: *common. Example:service-name: extends: file: docker-compose.service-name.yml service: service-name <<: *common - Allow all other containers to talk to the service via hostname by updating:
extra_hostsin the "common" variable at the top ofdocker-compose.ymllike:- "service-name:host-gateway"- the list that
audius-compose connectuses in the audius-compose Python script in this directory to includeservice-name
- Import the same service in
docker-compose.test.yml, if needed, to build+test in CI - Optionally, add a flag to the
upsubcommand in the audius-compose Python script in this directory if you want to do something like skip bringing up this service by default (helpful for expensive services)