diff --git a/.gitea/workflows/container.yml b/.gitea/workflows/container.yml index a26913a..5640830 100644 --- a/.gitea/workflows/container.yml +++ b/.gitea/workflows/container.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: - target: [DATABASE, BOT, WEB] + target: [database, bot, web] steps: - name: Checkout diff --git a/Dockerfile b/Dockerfile index cf4a2b0..18b97c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/README.md b/README.md index 8615ed0..13673ae 100644 --- a/README.md +++ b/README.md @@ -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 -``` +To add a new technology, just type: -```bash -/tech list -``` +/add -```bash -/tech search -``` +To list all technologies, just type: + +/list + + +To search for a technology, just type: + +/search + + +To remove a technology, you need to have the permission to remote a tech from the list. +If so, just type: + +/remove + + +To update a technology, you need to have the permission to update a tech from the list. +If so, just type: + +/update + + +To get help, just type: + +/help -```bash -/tech remove ```