Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
endline committed Dec 6, 2024
1 parent 7fb3b54 commit 522a04a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 31 deletions.
10 changes: 5 additions & 5 deletions cmd/audiusd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ EXPOSE 80
EXPOSE 443
EXPOSE 26656

# Make sure the data directory exists and has correct permissions
RUN mkdir -p /var/lib/postgresql/data && \
chown -R postgres:postgres /var/lib/postgresql/data && \
chmod -R 700 /var/lib/postgresql/data
# Set up data directory structure
RUN mkdir -p /data/postgres && \
chown -R postgres:postgres /data/postgres && \
chmod -R 700 /data/postgres

VOLUME ["/var/lib/postgresql/data"]
# Single volume mount point
VOLUME ["/data"]

ENTRYPOINT ["/bin/entrypoint.sh"]
26 changes: 23 additions & 3 deletions cmd/audiusd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A golang implementation of the audius protocol.
Minimal example to run a node and sync it to the audius mainnet.

```bash
docker run --rm -ti -p 80:80 audius/audiusd:latest
docker run --rm -ti -p 80:80 audius/audiusd:current

open http://localhost/console/overview
```
Expand All @@ -17,8 +17,8 @@ open http://localhost/console/overview
To operate a [registered](https://docs.audius.org/node-operator/setup/registration/) node requires the minimal config below.

```bash
# directory for data persistence
mkdir ~/.audiusd
# directory for data and configuration persistence
mkdir -p ~/.audiusd

cat <<EOF > ~/.audiusd/override.env
creatorNodeEndpoint=https://
Expand All @@ -31,6 +31,12 @@ EOF
docker run -d -ti --env-file ~/.audiusd/override.env -v ~/.audiusd/data:/data -p 80:80 -p 443:443 -p 26656:26656 audius/audiusd:latest
```

If you are migrating from an **existing registered production node**, you will want to pay attention to the persistent volume mount point. Which will likely look something more like this:

```bash
docker run -d -ti --env-file ~/.audiusd/override.env -v /var/k8s:/data -p 80:80 -p 443:443 -p 26656:26656 audius/audiusd:latest
```

### P2P Ports

Port `26656` must be open and accessible for your node to fully participate in the Audius network, enabling it to propose blocks, vote in consensus, and relay transactions to other nodes.
Expand All @@ -44,3 +50,17 @@ To enable TLS, set `ENABLE_TLS=true` in your environment. This will instruct `au
For this to function correctly, the following conditions must be met:
- Your service must be publicly accessible via the URL specified in the `creatorNodeEndpoint` environment variable.
- Your service must be reachable on both port `:80` and port `:443`

## Development

```
make build-audiusd-local
# sync a local node to stage
docker run --rm -ti -p 80:80 -e NETWORK=stage audius/audiusd:$(git rev-parse HEAD)
open http://localhost/console/overview
# network defaults to prod out of box, for an unregistered, RPC node
# tag would be "current" after this PR merges
docker run --rm -ti -p 80:80 audius/audiusd:$(git rev-parse HEAD)
```
48 changes: 28 additions & 20 deletions cmd/audiusd/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
#!/bin/bash

# Default to prod if NETWORK is not set
NETWORK=${NETWORK:-prod}
# Set default network to prod if not specified
NETWORK="${NETWORK:-prod}"
ENV_FILE="/env/${NETWORK}.env"
OVERRIDE_ENV_FILE="/env/override.env"

# Validate environment files exist
if [ ! -f "$ENV_FILE" ]; then
echo "Error: Network environment file not found at $ENV_FILE"
exit 1
fi

# source environment variables without overwriting existing ones
source_env_file() {
local file=$1
if [ -f "$file" ]; then
echo "Sourcing environment variables from $file"
while IFS='=' read -r key value || [ -n "$key" ]; do
# skip lines that are comments or empty
[[ "$key" =~ ^#.*$ ]] && continue
[[ -z "$key" ]] && continue
# only set variables that are not already defined (prioritize docker-passed env)
if [ -z "${!key}" ]; then
# strip quotations
val="${value%\"}"
val="${val#\"}"
export "$key"="$val"
fi
done < "$file"
else
echo "Environment file $file not found!"
if [ ! -f "$file" ]; then
echo "Environment file $file not found"
return
fi

echo "Loading environment from $file"
while IFS='=' read -r key value || [ -n "$key" ]; do
# skip comments and empty lines
[[ "$key" =~ ^#.*$ ]] && continue
[[ -z "$key" ]] && continue

# only set if not already defined (prioritize docker-passed env)
if [ -z "${!key}" ]; then
# strip quotations
val="${value%\"}"
val="${val#\"}"
export "$key"="$val"
fi
done < "$file"
}

source_env_file "$ENV_FILE"
Expand All @@ -33,10 +41,10 @@ source_env_file "$OVERRIDE_ENV_FILE"
# minimum values for a core node to just run
POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB=${POSTGRES_DB:-audiusd}
POSTGRES_DATA_DIR=${POSTGRES_DATA_DIR:-/var/lib/postgresql/data}
POSTGRES_DATA_DIR=${POSTGRES_DATA_DIR:-/data/postgres}
export dbUrl=${dbUrl:-postgresql://postgres:postgres@localhost:5432/audiusd?sslmode=disable}
export uptimeDataDir=${uptimeDataDir:-/data/bolt}
export audius_core_root_dir=${audius_core_root_dir:-/data/audiusd}
export audius_core_root_dir=${audius_core_root_dir:-/data/core}
export creatorNodeEndpoint=${creatorNodeEndpoint:-http://localhost}

setup_postgres() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/audiusd/env/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ ethProviderUrl=http://eth-ganache.devnet.audius-d
ethRegistryAddress=0xABbfF712977dB51f9f212B85e8A4904c818C2b63
MEDIORUM_ENV=sandbox
identityService=https://identity.devnet.audius-d
audius_core_root_dir=/audius-core
audius_core_root_dir=/data/core
uptimeDataDir=/bolt
2 changes: 1 addition & 1 deletion cmd/audiusd/env/prod.env
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ rewardsManagerProgramPda=71hWFVYokLaN1PNYzTAWi13EfJ7Xt9VbSWUKsXUT8mxE
rewardsManagerTokenPda=3V9opXNpHmPPymKeq7CYD8wWMH8wzFXmqEkNdzfsZhYq

# Core
audius_core_root_dir=/audius-core
audius_core_root_dir=/data/core
uptimeDataDir=/bolt
2 changes: 1 addition & 1 deletion cmd/audiusd/env/stage.env
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ rewardsManagerProgramPda=GaiG9LDYHfZGqeNaoGRzFEnLiwUT7WiC6sA6FDJX9ZPq
rewardsManagerTokenPda=HJQj8P47BdA7ugjQEn45LaESYrxhiZDygmukt8iumFZJ

# Core
audius_core_root_dir=/audius-core
audius_core_root_dir=/data/core
uptimeDataDir=/bolt

0 comments on commit 522a04a

Please sign in to comment.