Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flyio config #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dist
!index.ts
!character.ts
.env
node_modules
dist/

db.sqlite
.idea
25 changes: 17 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# Required environment variables
DISCORD_APPLICATION_ID=
DISCORD_API_TOKEN= # Bot token
OPENAI_API_KEY=sk-* # OpenAI API key, starting with sk-
GITBOOK_SPACE_ID=
TWITTER_USERNAME=
TWITTER_PASSWORD=
TWITTER_EMAIL=
POST_INTERVAL_MIN=1
POST_INTERVAL_MAX=3
# When true, disables interactive chat mode for background process operation
DAEMON_PROCESS=false # true for server deployment
TELEGRAM_BOT_TOKEN=
DATABASE_URL=





DISCORD_API_TOKEN= # Bot token

REDPILL_API_KEY= # REDPILL API Key
GROK_API_KEY= # GROK API Key
GROQ_API_KEY=gsk_*
Expand Down Expand Up @@ -79,16 +95,9 @@ BASE_MINT=So11111111111111111111111111111111111111112
RPC_URL=https://api.mainnet-beta.solana.com
HELIUS_API_KEY=


## Telegram
TELEGRAM_BOT_TOKEN=

TOGETHER_API_KEY=
SERVER_PORT=3000

# Starknet
STARKNET_ADDRESS=
STARKNET_PRIVATE_KEY=

# When true, disables interactive chat mode for background process operation
DAEMON_PROCESS=false
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
123 changes: 86 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,102 @@
# Use a specific Node.js version for better reproducibility
FROM node:23.3.0-slim AS builder
# # Use a specific Node.js version for better reproducibility
# FROM node:23.3.0-slim AS builder

# # Install pnpm globally and install necessary build tools
# RUN npm install -g [email protected] && \
# apt-get update && \
# apt-get install -y git python3 make g++ && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*

# # Set Python 3 as the default python
# RUN ln -s /usr/bin/python3 /usr/bin/python

# # Set the working directory
# WORKDIR /app

# # Copy package.json and other configuration files
# COPY package.json ./
# COPY pnpm-lock.yaml ./
# COPY tsconfig.json ./

# # Copy the rest of the application code
# COPY ./src ./src
# COPY ./characters ./characters

# # Install dependencies and build the project
# RUN pnpm install --frozen-lockfile
# RUN pnpm build

# # Create dist directory and set permissions
# RUN mkdir -p /app/dist && \
# chown -R node:node /app && \
# chmod -R 755 /app

# # Switch to node user
# USER node

# # Create a new stage for the final image
# FROM node:23.3.0-slim

# # Install runtime dependencies if needed
# RUN npm install -g [email protected]
# RUN apt-get update && \
# apt-get install -y git python3 && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*

# WORKDIR /app

# Copy built artifacts and production dependencies from the builder stage
# COPY --from=builder /app/package.json /app/
# COPY --from=builder /app/node_modules /app/node_modules
# COPY --from=builder /app/src /app/src
# COPY --from=builder /app/characters /app/characters
# COPY --from=builder /app/dist /app/dist
# COPY --from=builder /app/tsconfig.json /app/
# COPY --from=builder /app/pnpm-lock.yaml /app/

# Install pnpm globally and install necessary build tools
RUN npm install -g [email protected] && \
apt-get update && \
apt-get install -y git python3 make g++ && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# EXPOSE 3000
# # Set the command to run the application
# CMD ["pnpm", "start", '--character="characters/harmony.character.json"']
# # CMD ["pnpm", "start", "--non-interactive", '--character="characters/harmony.character.json"']

# Set Python 3 as the default python
RUN ln -s /usr/bin/python3 /usr/bin/python

# Set the working directory
# Modified Dockerfile optimizations

FROM node:23.3.0-slim AS builder

WORKDIR /app

# Copy package.json and other configuration files
COPY package.json ./
COPY pnpm-lock.yaml ./
COPY tsconfig.json ./
RUN apt-get update && \
apt-get install -y \
python3 \
python-is-python3 \
make \
g++ \
git \
&& rm -rf /var/lib/apt/lists/*

# Copy the rest of the application code
COPY ./src ./src
COPY ./characters ./characters
RUN npm install -g [email protected]

# Install dependencies and build the project
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
RUN pnpm build

# Create dist directory and set permissions
RUN mkdir -p /app/dist && \
chown -R node:node /app && \
chmod -R 755 /app

# Switch to node user
USER node
COPY . .
RUN pnpm build

# Create a new stage for the final image
FROM node:23.3.0-slim

# Install runtime dependencies if needed
RUN npm install -g [email protected]
WORKDIR /app

RUN apt-get update && \
apt-get install -y git python3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
apt-get install -y \
python3 \
python-is-python3 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
RUN npm install -g [email protected]

# Copy built artifacts and production dependencies from the builder stage
COPY --from=builder /app/package.json /app/
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/src /app/src
Expand All @@ -57,5 +106,5 @@ COPY --from=builder /app/tsconfig.json /app/
COPY --from=builder /app/pnpm-lock.yaml /app/

EXPOSE 3000
# Set the command to run the application
CMD ["pnpm", "start", "--non-interactive"]

CMD pnpm start --character="characters/harmonious.character.json" --non-interactive
55 changes: 42 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Eliza

## Prerequisites
### Postgres Database Setup
This project requires a Postgres database with the pgvector extension. For detailed instructions on setting up Postgres with pgvector on Fly.io, please refer to the [setup guide](postgres-docker-config/README.md).

## Edit the character files

Open `src/character.ts` to modify the default character. Uncomment and edit.
Expand All @@ -19,25 +23,39 @@ clients: [Clients.TWITTER, Clients.DISCORD],
clients: ["twitter", "discord"]
```

## Duplicate the .env.example template
## Environment Setup

### Required Environment Variables
The following environment variables are required for the application to run:

```bash
# Core Variables (Required)
DAEMON_PROCESS=true # Important: Must be true in production to disable interactive mode
SERVER_PORT=3000 # The port your service will run on
DATABASE_URL # Your PostgreSQL database connection string

# Model Provider (At least one required)
OPENAI_API_KEY # OpenAI API key for GPT models
# OR
OPENROUTER_API_KEY # OpenRouter API key for alternative models

# Optional Client-Specific Variables (Required if using specific clients)
DISCORD_APPLICATION_ID # Required for Discord integration
DISCORD_API_TOKEN # Required for Discord bot functionality
TELEGRAM_BOT_TOKEN # Required for Telegram bot functionality
GITBOOK_SPACE_ID # Required for Gitbook integration
```

### Development Setup
1. Duplicate the .env.example template:
```bash
cp .env.example .env
```

\* Fill out the .env file with your own values.
2. Fill out the .env file with your own values.

### Add login credentials and keys to .env
```
DISCORD_APPLICATION_ID="discord-application-id"
DISCORD_API_TOKEN="discord-api-token"
...
OPENROUTER_API_KEY="sk-xx-xx-xxx"
...
TWITTER_USERNAME="username"
TWITTER_PASSWORD="password"
TWITTER_EMAIL="[email protected]"
```
### Production Deployment
When deploying to production (e.g., Fly.io), ensure these minimum environment variables are set:

## Install dependencies and start your agent

Expand Down Expand Up @@ -87,3 +105,14 @@ services:
```bash
docker compose -f docker-compose-image.yaml up
```

## Memory Requirements

The application requires a minimum of 2GB RAM to run properly. For production environments, it's recommended to:
- Use at least 2GB RAM per instance
- Or enable multiple machines with load balancing if using smaller memory configurations

You can adjust memory in Fly.io using:
```bash
fly scale memory 2048 # Scales to 2GB RAM
```
Loading