Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ FROM nginx:latest
COPY --from=build /app/build /usr/share/nginx/html

COPY --from=build /app/scripts/nginx.conf /etc/nginx/nginx.conf

# Copy and set up the entrypoint script
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The CADT UI can be hosted as a web application, either for internal use, or made

To host the UI on the web, use the [web-build.tar.gz file from the releases page](https://github.com/Chia-Network/cadt-ui/releases). One of the simplest solutions is to uncompress these files into a [public S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteAccessPermissionsReqd.html). These files could also be served by any webserver, such as Nginx or Apache.

To make the CADT UI web application automatically connect to a CADT host by default, copy the `config.example.json` file to `config.json` and change the `apiHost` to be the CADT API hostname, including http:// and the path (everything before the `/v1` part of the API URL)
To make the CADT UI web application automatically connect to a CADT host by default, copy the `public/config.example.json` file to `config.json` and change the `apiHost` to be the CADT API hostname, including http:// and the path (everything before the `/v1` part of the API URL)

#### Sample Nginx Config

Expand All @@ -77,6 +77,75 @@ server {

```

### Docker Container

The CADT UI is available as a Docker container from the [packages section](https://github.com/Chia-Network/cadt-ui/pkgs/container/cadt-ui) of the GitHub repository. This provides an easy way to deploy the UI as a web application with configurable API endpoints and custom styling.

#### Quick Start

```bash
docker run -p 8099:80 ghcr.io/chia-network/cadt-ui:latest
```

This will start the CADT UI on port 8099. You can access it at `http://localhost:8099`.

#### Environment Variables

The Docker container supports several environment variables for configuration:

##### API Configuration

- **`API_HOST`** - Sets the CADT API host URL that the UI will connect to automatically
- When set, creates a `config.json` file in the webroot with the specified API host

##### UI Customization

- **`LEFTNAVBG`** - Background color for the left navigation panel
- Example: `rgb(0, 242, 245)` or `#00f2f5`
- **`LEFTNAVTEXT`** - Text color for the left navigation panel
- Example: `#ff0005` or `rgb(255, 0, 5)`
- **`LEFTNAVITEMACTIVE`** - Color for active navigation items
- Example: `blue` or `#0066cc`

When any of these color variables are set, a `colors.json` file is created in the webroot with the specified values.

#### Usage Examples

**Basic usage with custom API host:**
```bash
docker run -p 8099:80 \
-e API_HOST="https://cadt-api.example.com" \
ghcr.io/chia-network/cadt-ui:latest
```

**Full customization with API host and custom colors:**
```bash
docker run -p 8099:80 \
-e API_HOST="https://cadt-api.example.com" \
-e LEFTNAVBG="rgb(0, 242, 245)" \
-e LEFTNAVTEXT="#ff0005" \
-e LEFTNAVITEMACTIVE="blue" \
ghcr.io/chia-network/cadt-ui:latest
```

#### Docker Compose Example

For easier management, you can use Docker Compose:

```yaml
version: '3.8'
services:
cadt-ui:
image: ghcr.io/chia-network/cadt-ui:latest
ports:
- "8099:80"
environment:
- API_HOST=https://cadt-api.example.com
- LEFTNAVBG=rgb(0, 242, 245)
- LEFTNAVTEXT=#ff0005
- LEFTNAVITEMACTIVE=blue
restart: unless-stopped
```

### From Source

Expand Down
45 changes: 45 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Create config.json if API_HOST environment variable is set
if [ ! -z "$API_HOST" ]; then
echo "{\"apiHost\": \"$API_HOST\"}" > /usr/share/nginx/html/config.json
fi

# Create colors.json if any color environment variables are set
if [ ! -z "$LEFTNAVBG" ] || [ ! -z "$LEFTNAVTEXT" ] || [ ! -z "$LEFTNAVITEMACTIVE" ]; then
echo "{" > /usr/share/nginx/html/colors.json

# Track if we need a comma before the next property
first_property=true

# Add leftNavBg if set
if [ ! -z "$LEFTNAVBG" ]; then
if [ "$first_property" = false ]; then
echo "," >> /usr/share/nginx/html/colors.json
fi
echo " \"leftNavBg\": \"$LEFTNAVBG\"" >> /usr/share/nginx/html/colors.json
first_property=false
fi

# Add leftNavText if set
if [ ! -z "$LEFTNAVTEXT" ]; then
if [ "$first_property" = false ]; then
echo "," >> /usr/share/nginx/html/colors.json
fi
echo " \"leftNavText\": \"$LEFTNAVTEXT\"" >> /usr/share/nginx/html/colors.json
first_property=false
fi

# Add leftNavItemActive if set
if [ ! -z "$LEFTNAVITEMACTIVE" ]; then
if [ "$first_property" = false ]; then
echo "," >> /usr/share/nginx/html/colors.json
fi
echo " \"leftNavItemActive\": \"$LEFTNAVITEMACTIVE\"" >> /usr/share/nginx/html/colors.json
first_property=false
fi

echo "}" >> /usr/share/nginx/html/colors.json
fi

exec "$@"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cadt-ui",
"private": true,
"version": "2.0.9",
"version": "2.0.10",
"type": "module",
"main": "build/main.js",
"engineStrict": true,
Expand Down
Loading