Skip to content

Commit

Permalink
Merge branch 'master' into messagelink
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx authored Jun 2, 2024
2 parents d1dcb19 + 092a80c commit f130e96
Show file tree
Hide file tree
Showing 846 changed files with 29,221 additions and 34,791 deletions.
10 changes: 9 additions & 1 deletion .clabot
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
"iamshoXy",
"Scraayp",
"app/dependabot",
"zayKenyon"
"dependabot[bot]",
"zayKenyon",
"rukogit",
"Obliie",
"brawaru",
"Benricheson101",
"hawkeye7662",
"LilyBergonzat",
"martinbndr"
],
"message": "Thank you for contributing to Zeppelin! We require contributors to sign our Contributor License Agreement (CLA). To let us review and merge your code, please visit https://github.com/ZeppelinBot/CLA to sign the CLA!"
}
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

"service": "devenv",
"remoteUser": "ubuntu",
"workspaceFolder": "/home/ubuntu/zeppelin"
"workspaceFolder": "/workspace/zeppelin"
}
47 changes: 40 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
.git
.github
.idea
.devcontainer
**/.git
**/.github
**/.idea
**/.devcontainer

/docker/development/data
/docker/production/data

node_modules
/backend/dist
/dashboard/dist
**/node_modules
**/dist

**/*.log
**/npm-debug.log*
**/yarn-debug.log*
**/yarn-error.log*
**/.clinic
**/.clinic-bot
**/.clinic-api

# dotenv environment variables file
**/*.env
**/.env

# windows folder options
**/desktop.ini

# PHPStorm
**/.idea

# Misc
**/npm-ls.txt
**/npm-audit.txt
**/.cache

# Debug files
**/*.debug.ts
**/*.debug.js

**/.vscode

config-errors.txt
/config-schema.json

**/*.tsbuildinfo
78 changes: 44 additions & 34 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ==========================
# GENERAL OPTIONS
# ==========================

# 32 character encryption key
KEY=

Expand All @@ -17,58 +21,64 @@ STAFF=
# A comma-separated list of server IDs that should be allowed by default
DEFAULT_ALLOWED_SERVERS=

# When using the Docker-based development environment, this is only used internally. The API will be available at localhost:DOCKER_DEV_WEB_PORT/api.
API_PORT=3000

# Only required if relevant feature is used
#PHISHERMAN_API_KEY=

# The user ID and group ID that should be used within the Docker containers
# This should match your own user ID and group ID. Run `id -u` and `id -g` to find them.
DOCKER_USER_UID=
DOCKER_USER_GID=

#
# DOCKER (DEVELOPMENT)
# NOTE: You only need to fill in these values for running the development environment. See production config further below.
#
# ==========================
# DEVELOPMENT
# NOTE: You only need to fill in these values for running the development environment
# ==========================

DOCKER_DEV_WEB_PORT=3300
DEVELOPMENT_WEB_PORT=3300

# The MySQL database running in the container is exposed to the host on this port,
# allowing access with database tools such as DBeaver
DOCKER_DEV_MYSQL_PORT=3001
DEVELOPMENT_MYSQL_PORT=3356
# Password for the Zeppelin database user
DOCKER_DEV_MYSQL_PASSWORD=
DEVELOPMENT_MYSQL_PASSWORD=password
# Password for the MySQL root user
DOCKER_DEV_MYSQL_ROOT_PASSWORD=
DEVELOPMENT_MYSQL_ROOT_PASSWORD=password

# The development environment container has an SSH server that you can connect to.
# This is the port that server is exposed to the host on.
DOCKER_DEV_SSH_PORT=3002
DOCKER_DEV_SSH_PASSWORD=password
DEVELOPMENT_SSH_PORT=3022
DEVELOPMENT_SSH_PASSWORD=password

# If your user has a different UID than 1000, you might have to fill that in here to avoid permission issues
#DOCKER_DEV_UID=1000
#DEVELOPMENT_UID=1000


#
# DOCKER (PRODUCTION)
# NOTE: You only need to fill in these values for running the production environment. See development config above.
#
# ==========================
# PRODUCTION - STANDALONE
# NOTE: You only need to fill in these values for running the standalone production environment
# ==========================

STANDALONE_WEB_PORT=80

DOCKER_PROD_DOMAIN=
DOCKER_PROD_WEB_PORT=443
# The MySQL database running in the container is exposed to the host on this port,
# allowing access with database tools such as DBeaver
DOCKER_PROD_MYSQL_PORT=3001
STANDALONE_MYSQL_PORT=3356
# Password for the Zeppelin database user
DOCKER_PROD_MYSQL_PASSWORD=
STANDALONE_MYSQL_PASSWORD=
# Password for the MySQL root user
DOCKER_PROD_MYSQL_ROOT_PASSWORD=

# You only need to set these if you're running an external database.
# In a standard setup, the database is run in a docker container.
#DB_HOST=
#DB_USER=
#DB_PASSWORD=
#DB_DATABASE=
STANDALONE_MYSQL_ROOT_PASSWORD=


# ==========================
# PRODUCTION - LIGHTWEIGHT
# NOTE: You only need to fill in these values for running the lightweight production environment
# ==========================

# Ports where the API/dashboard are exposed on the host
LIGHTWEIGHT_API_PORT=3001
LIGHTWEIGHT_DASHBOARD_PORT=3002

LIGHTWEIGHT_DB_HOST=
LIGHTWEIGHT_DB_PORT=
LIGHTWEIGHT_DB_USER=
LIGHTWEIGHT_DB_PASSWORD=
LIGHTWEIGHT_DB_DATABASE=

# If you want to add a prefix to API paths, such as /api, you can set that here
LIGHTWEIGHT_API_PATH_PREFIX=
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json binary
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ npm-audit.txt
*.debug.js

.vscode/

config-errors.txt
/config-schema.json

*.tsbuildinfo

# Legacy data folders
/docker/development/data
/docker/production/data
72 changes: 1 addition & 71 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,71 +1 @@
# Zeppelin development environment
Zeppelin's development environment runs entirely within a Docker container.
Below you can find instructions for setting up the environment and getting started with development!

**Note:** If you'd just like to run the bot for your own server, see 👉 **[PRODUCTION.md](./PRODUCTION.md)** 👈

## Starting the development environment

### Using VSCode devcontainers
1. Install Docker
2. Make a copy of `.env.example` called `.env`
3. Fill in the missing values in `.env`
4. In VSCode: Install the `Remote - Containers` plugin
5. In VSCode: Run `Remote-Containers: Open Folder in Container...` and select the Zeppelin folder

### Using VSCode remote SSH plugin
1. Install Docker
2. Make a copy of `.env.example` called `.env`
3. Fill in the missing values in `.env`
4. Run `docker compose -f docker-compose.development.yml up` to start the development environment
5. In VSCode: Install the `Remote - SSH` plugin
6. In VSCode: Run `Remote-SSH: Connect to Host...`
* As the address, use `[email protected]:3002` (where `3002` matches `DOCKER_DEV_SSH_PORT` in `.env`)
* Use the password specified in `.env` as `DOCKER_DEV_SSH_PASSWORD`
7. In VSCode: Once connected, click `Open folder...` and select `/home/ubuntu/zeppelin`

### Using JetBrains Gateway
1. Install Docker
2. Make a copy of `.env.example` called `.env`
3. Fill in the missing values in `.env`
4. Run `docker compose -f docker-compose.development.yml up` to start the development environment
5. Choose `Connect via SSH` and create a new connection:
* Username: `ubuntu`
* Host: `127.0.0.1`
* Port: `3002` (matching the `DOCKER_DEV_SSH_PORT` value in `.env`)
6. Click `Check Connection and Continue` and enter the password specified in `.env` as `DOCKER_DEV_SSH_PASSWORD` when asked
7. In the next pane:
* IDE version: WebStorm, PHPStorm, or IntelliJ IDEA
* Project directory: `/home/ubuntu/zeppelin`
8. Click `Download and Start IDE`

### Using any other IDE with SSH development support
1. Install Docker
2. Make a copy of `.env.example` called `.env`
3. Fill in the missing values in `.env`
4. Run `docker compose -f docker-compose.development.yml up` to start the development environment
5. Use the following credentials for connecting with your IDE:
* Host: `127.0.0.1`
* Port: `3002` (matching the `DOCKER_DEV_SSH_PORT` value in `.env`)
* Username: `ubuntu`
* Password: As specified in `.env` as `DOCKER_DEV_SSH_PASSWORD`

## Starting the project

### Starting the backend (bot + api)
These commands are run inside the dev container. You should be able to open a terminal in your IDE after connecting.

1. `cd ~/zeppelin/backend`
2. `npm ci`
3. `npm run migrate-dev`
4. `npm run watch`

### Starting the dashboard
These commands are run inside the dev container. You should be able to open a terminal in your IDE after connecting.

1. `cd ~/zeppelin/dashboard`
2. `npm ci`
3. `npm run watch-build`

### Opening the dashboard
Browse to https://localhost:3300 to view the dashboard
Moved to [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:20

RUN mkdir /zeppelin
RUN chown node:node /zeppelin

USER node

ARG API_URL

# Install dependencies before copying over any other files
COPY --chown=node:node package.json package-lock.json /zeppelin
RUN mkdir /zeppelin/backend
COPY --chown=node:node backend/package.json /zeppelin/backend
RUN mkdir /zeppelin/shared
COPY --chown=node:node shared/package.json /zeppelin/shared
RUN mkdir /zeppelin/dashboard
COPY --chown=node:node dashboard/package.json /zeppelin/dashboard

WORKDIR /zeppelin
RUN npm ci

COPY --chown=node:node . /zeppelin

# Build backend
WORKDIR /zeppelin/backend
RUN npm run build

# Build dashboard
WORKDIR /zeppelin/dashboard
RUN npm run build

# Prune dev dependencies
WORKDIR /zeppelin
RUN npm prune --omit=dev
35 changes: 1 addition & 34 deletions MANAGEMENT.md
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
# Management
After starting Zeppelin -- either in the [development](./DEVELOPMENT.md) or [production](./PRODUCTION.md) environment -- you have several tools available to manage it.

## Note
Make sure to add yourself to the list of staff members (`STAFF`) in `.env` and allow at least one server by default (`DEFAULT_ALLOWED_SERVERS`). Then, invite the bot to the server.

In all examples below, `@Bot` refers to a user mention of the bot user. Make sure to run the commands on a server with the bot, in a channel that the bot can see.

In the command parameters, `<this>` refers to a required parameter (don't include the `< >` symbols) and `[this]` refers to an optional parameter (don't include the `[ ]` symbols). `<this...>` refers to being able to list multiple values, e.g. `value1 value2 value3`.

## Allow a server to invite the bot
Run the following command:
```
@Bot allow_server <serverId> [userId]
```
When specifying a user ID, that user will be given "Bot manager" level access to the server's dashboard, allowing them to manage access for other users.

## Disallow a server
Run the following command:
```
@Bot disallow_server <serverId>
```

## Grant access to a server's dashboard
Run the following command:
```
@Bot add_dashboard_user <serverId> <userId...>
```

## Remove access to a server's dashboard
Run the following command:
```
@Bot remove_dashboard_user <serverId> <userId...>
```
Moved to [docs/MANAGEMENT.md](docs/MANAGEMENT.md)
35 changes: 1 addition & 34 deletions PRODUCTION.md
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
# Zeppelin production environment
Zeppelin's production environment - that is, the **bot, API, and dashboard** - uses Docker.

## Starting the production environment
1. Install Docker on the machine running the bot
2. Make a copy of `.env.example` called `.env`
3. Fill in the missing values in `.env`
4. Run `docker compose -f docker-compose.production.yml build`
5. Run `docker compose -f docker-compose.production.yml up -d`

**Note:** The dashboard and API are exposed with a self-signed certificate. It is recommended to set up a proxy with a proper certificate in front of them. Cloudflare is a popular choice here.

## Updating the bot

### One-click script
If you've downloaded the bot's files by cloning the git repository, you can use `update.sh` to update the bot.

### Manual instructions
1. Shut the bot down: `docker compose -f docker-compose.production.yml down`
2. Update the files (e.g. `git pull`)
3. Build new images: `docker compose -f docker-compose.production.yml build`
3. Start the bot again: `docker compose -f docker-compose.production.yml up -d`

### Ephemeral hotfixes
If you need to make a hotfix to the bot's source files directly on the server:
1. Shut the bot down: `docker compose -f docker-compose.production.yml down`
2. Make your edits
3. Build new images: `docker compose -f docker-compose.production.yml build`
4. Start the bot again: `docker compose -f docker-compose.production.yml up -d`

Make sure to revert any hotfixes before updating the bot normally.

## View logs
To view real-time logs, run `docker compose -f docker-compose.production.yml logs -t -f`
Moved to [docs/PRODUCTION.md](docs/PRODUCTION.md)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ See https://zeppelin.gg/ for more details.
For information on how to use the bot, see https://zeppelin.gg/docs

## Development
See [DEVELOPMENT.md](./DEVELOPMENT.md) for instructions on running the development environment.
See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for instructions on running the development environment.

Once you have the environment up and running, see [MANAGEMENT.md](./MANAGEMENT.md) for how to manage your bot.
Once you have the environment up and running, see [docs/MANAGEMENT.md](docs/MANAGEMENT.md) for how to manage your bot.

## Production
See [PRODUCTION.md](./PRODUCTION.md) for instructions on how to run the bot in production.
See [docs/PRODUCTION.md](docs/PRODUCTION.md) for instructions on how to run the bot in production.

Once you have the environment up and running, see [MANAGEMENT.md](./MANAGEMENT.md) for how to manage your bot.
Once you have the environment up and running, see [docs/MANAGEMENT.md](docs/MANAGEMENT.md) for how to manage your bot.
Loading

0 comments on commit f130e96

Please sign in to comment.