update doc
Docker / Build and push Docker image (web) (push) Failing after 20m18s Details
Docker / Build and push Docker image (bot) (push) Failing after 22m58s Details
Docker / Build and push Docker image (database) (push) Successful in 26m42s Details

This commit is contained in:
DataHearth 2023-08-07 11:38:01 +02:00
parent b08c4fffa2
commit 20ff50e5af
No known key found for this signature in database
GPG Key ID: E88FD356ACC5F3C4
3 changed files with 95 additions and 41 deletions

View File

@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
target: [DATABASE, BOT, WEB]
target: [database, bot, web]
steps:
- name: Checkout

View File

@ -2,7 +2,7 @@
# * Build the bot and database *
# ********************************
FROM rust:1 as RUST-BUILDER
FROM rust:1 as rust-builder
WORKDIR /app
@ -14,9 +14,9 @@ RUN cargo build --release
# * Deploy the bot *
# ********************************
FROM gcr.io/distroless/cc as BOT
FROM gcr.io/distroless/cc as bot
COPY --from=RUST-BUILDER /app/target/release/bot /bot
COPY --from=rust-builder /app/target/release/bot /bot
CMD [ "/bot" ]
@ -24,9 +24,9 @@ CMD [ "/bot" ]
# * Deploy the database *
# ********************************
FROM gcr.io/distroless/cc as DATABASE
FROM gcr.io/distroless/cc as database
COPY --from=RUST-BUILDER /app/target/release/database /database
COPY --from=rust-builder /app/target/release/database /database
ENV DB_PATH=/app/tech-bot.db
@ -40,7 +40,7 @@ CMD [ "/database" ]
# * Build the web *
# ********************************
FROM node:18-slim as WEB-BUILDER
FROM node:18-slim as web-builder
WORKDIR /app
@ -54,21 +54,15 @@ RUN corepack enable
RUN pnpm install --prod --frozen-lockfile
RUN pnpm build
FROM node:18-alpine3.18 as WEB
FROM node:18-alpine3.18 as web
WORKDIR /app
COPY --from=WEB-BUILDER /app/build ./build
COPY --from=WEB-BUILDER /app/node_modules ./node_modules
COPY --from=WEB-BUILDER /app/package.json /app/pnpm-lock.yaml ./
COPY --from=web-builder /app/build ./build
COPY --from=web-builder /app/node_modules ./node_modules
COPY --from=web-builder /app/package.json /app/pnpm-lock.yaml ./
ENV PORT=3000
ENV HOST=127.0.0.1
ENV DOTENV_CONFIG_PATH=/app/config/.env
ENV ORIGIN="http://localhost:3000"
ENV PUBLIC_GRAPHQL_ENDPOINT="http://localhost:8080/graphql"
EXPOSE ${PORT}
VOLUME [ "/app/config" ]

108
README.md
View File

@ -11,50 +11,110 @@ Save technologies you want to share/remember in a simple way inside Discord.
#### Docker
```bash
# BOT
export DISCORD_TOKEN=TOKEN
export ADMIN_USERS=123456789,987654321
export GRAPHQL_ENDPOINT="http://host/graphql"
# DATABASE
export DB_PATH="/path/to/db/database.db"
# FRONTEND
export FRONT_VOLUME
cat << EOF > $FRONT_VOLUME/.env
PORT=3000
HOST=127.0.0.1
PUBLIC_GRAPHQL_ENDPOINT="$GRAPHQL_ENDPOINT"
CLIENT_ID="DISCORD_APP_ID"
CLIENT_SECRET="DISCORD_APP_SECRET"
ORIGIN="http://host"
EOF
docker run -d \
--name tech-bot \
--name tech-bot-bot \
-e DISCORD_TOKEN=$DISCORD_TOKEN \
-e ADMIN_USERS=$ADMIN_USERS \
-v /path/to/tech-bot/data:/data \
-e GRAPHQL_ENDPOINT=$GRAPHQL_ENDPOINT \
--restart unless-stopped \
gitea.antoine-langlois.net/datahearth/tech-bot
gitea.antoine-langlois.net/datahearth/tech-bot:bot-latest
docker run -d \
--name tech-bot-database \
-v $DB_PATH:/app/database.db \
--restart unless-stopped \
gitea.antoine-langlois.net/datahearth/tech-bot:database-latest
docker run -d \
--name tech-bot-front \
-v $FRONT_VOLUME:/app/config \
-p ${EXTERNAL_PORT}:${INTERNAL_PORT} \
--restart unless-stopped \
gitea.antoine-langlois.net/datahearth/tech-bot:front-latest
```
#### Manually
```bash
export DISCORD_TOKEN=TOKEN
export ADMIN_USERS=123456789,987654321
export DB_PATH=database.db
# Setup
git clone https://gitea.antoine-langlois.net/datahearth/tech-bot.git
cd tech-bot
# Database & Bot
## Build
cargo build --release
./target/release/tech-bot
# Run
. ./target/release/tech-bot/database
. ./target/release/tech-bot/bot
# Frontend
cd frontend
## Build
pnpm install --prod --frozen-lockfile
pnpm build
## Run
export PORT=3000
export HOST=127.0.0.1
export PUBLIC_GRAPHQL_ENDPOINT="$GRAPHQL_ENDPOINT"
export CLIENT_ID="DISCORD_APP_ID"
export CLIENT_SECRET="DISCORD_APP_SECRET"
export ORIGIN="http://host"
node -r dotenv/config build
```
### Usage
```bash
/tech help
```
```text
Hello fellow human! I am a bot that can help you adding new technologies to a git repository.
```bash
/tech add <Technology name> <Technology link> <OPTIONAL: Technology tags (comma separated)>
```
To add a new technology, just type:
```bash
/tech list
```
/add <technology> <link>
```bash
/tech search <Technology name> <OPTIONAL: Regex> <OPTIONAL: Technology tags (comma separated)>
```
To list all technologies, just type:
/list
To search for a technology, just type:
/search <technology>
To remove a technology, you need to have the permission to remote a tech from the list.
If so, just type:
/remove <technology>
To update a technology, you need to have the permission to update a tech from the list.
If so, just type:
/update <UUID> <technology> <link> <tags>
To get help, just type:
/help
```bash
/tech remove <tech-name>
```