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

feat: update dependencies #7

Merged
merged 17 commits into from
Feb 20, 2024
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
DISCORD_TOKEN={DISCORD_TOKEN}
# url to the database
DATABASE_URL={DATABASE_URL}
# path to the database file (.yml)
DATABASE_PATH={DATABASE_PATH}
# debug levels are "minimal", "info", "success", "error", "verbose"
Expand Down
31 changes: 28 additions & 3 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,33 @@ on:
jobs:
build:
runs-on: ubuntu-latest
name: Build Pull Request

steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build --file ./Dockerfile .
- name: 📥 Checkout
uses: actions/checkout@v4

- name: ⚡️ Rust Cache
uses: Swatinem/rust-cache@v2

- name: ⚡️ Shared Compilation Cache
uses: mozilla-actions/sccache-action@v0.0.4

- name: 📦 Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential gcc cmake musl-dev pkg-config libpq-dev openssl libssl-dev

- name: 🛠️ Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: 🚀 Build
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
RUSTFLAGS: "-C target-feature=-crt-static"
run: |
cargo build --profile=ephemeral-build
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,16 @@ Cargo.lock

# Database folder
public/database/

# Jetbrains IDEs
.idea/
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# VS Code
.vscode/
.vscode/**/settings.json

8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/bostil-bot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .vscode/i18n-ally-custom-framework.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
languageIds:
- rust

usageMatchRegex:
# .add_string_choice(t!("commands.poll.management.label"), "management_command")
- "[^\\w\\d]t!\\([\\s\\n\\r]*['\"]({key})['\"]"

monopoly: true
46 changes: 28 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
[package]
name = "bostil-bot"
authors = ["Cassiano Rodrigues <kszinhu@modscleo4.dev.br>"]
repository = "https://github.com/kszinhu/bostil-bot"
version = "0.1.0"
edition = "2021"
[workspace]
resolver = "2"
members = ["app", "core"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
reqwest = { version = "*", features = ["json"] }
regex = "*"
[workspace.package]
authors = ["Cassiano Rodrigues <kszinhu@modscleo4.dev.br>"]
edition = "2021"

[workspace.dependencies]
# Discord
serenity = { default-features = false, features = [
"cache",
"client",
"http",
"framework",
"standard_framework",
"gateway",
"voice",
"rustls_backend",
"model",
], version = "*" }
songbird = { version = "*" }
tokio = { version = "*", features = ["macros", "rt-multi-thread", "signal"] }
serde = { version = "1.0.171", features = ["derive"] }
serde_json = "1.0.103"
once_cell = { version = "1.18.0", features = ["std"] }
rust-i18n = "2.0.0"
colored = "2.0.4"
yaml-rust = "0.4.5"
"collector",
], version = "0.12" }
songbird = { features = ["builtin-queue"], version = "0.4" }

# Logging
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
tracing-futures = "0.2"

# Other
lazy_static = "*"
once_cell = { version = "*", features = ["std"] }

[profile.ephemeral-build]
opt-level = 1
codegen-units = 8
inherits = "release"
67 changes: 33 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,61 @@
#----------------
# Build stage
#----------------
FROM rust:1.71.0-alpine3.17 as builder
FROM rust:1.76-alpine AS builder

ARG RUSTFLAGS="-C target-feature=-crt-static"
ARG APP=/usr/src/app
ARG TARGET_PLATFORM=x86_64-unknown-linux-musl
ARG CRATE_NAME=bostil-bot

# System dependencies
RUN apk add --no-cache \
build-base \
cmake \
musl-dev \
curl \
ffmpeg \
youtube-dl \
pkgconfig \
openssl-dev \
git
build-base cmake musl-dev pkgconfig openssl-dev \
libpq-dev \
curl git yt-dlp

WORKDIR /usr/src/app
WORKDIR ${APP}

RUN cargo new --bin bostil-bot
RUN cargo new --bin ${CRATE_NAME}

WORKDIR /usr/src/app/bostil-bot
WORKDIR ${APP}/${CRATE_NAME}

COPY Cargo.toml ./Cargo.toml
COPY public ./public
COPY src ./src
COPY Cargo.toml ./
COPY app ./app
COPY core ./core

# Build the dependencies
RUN cargo clean
RUN cargo build --release
RUN cargo install diesel_cli --no-default-features --features postgres

# Remove the source code
RUN rm src/**/*.rs
RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGET_PLATFORM} --mount=type=cache,target=/target,id=${TARGET_PLATFORM} \
cargo build --release && \
mv target/release/${CRATE_NAME} .

ADD . ./
COPY . .

# Remove the target directory
RUN rm ./target/release/deps/bostil_bot*
RUN --mount=type=cache,target=/usr/local/cargo/registry <<EOF
set -e
touch app/src/main.rs
cargo build --release
EOF

# Build the application
RUN cargo build --release
CMD ["/target/release/${CRATE_NAME}"]

#----------------
# Runtime stage
#----------------
FROM alpine:latest AS runtime
FROM alpine:3.19 AS runtime

ARG APP=/usr/src/app
ARG CRATE_NAME=bostil-bot

# System dependencies
RUN apk add --no-cache ca-certificates tzdata youtube-dl ffmpeg
RUN apk add --no-cache ca-certificates tzdata yt-dlp

# Copy the binary from the builder stage
COPY --from=builder /usr/src/app/bostil-bot/target/release/bostil-bot ${APP}/bostil-bot

# Copy public files from the builder stage
COPY --from=builder /usr/src/app/bostil-bot/public ${APP}/public
# COPY --from=builder ${APP}/bostil-bot/target/release/bostil-bot ${APP}/bostil-bot
COPY --from=builder ${APP}/${CRATE_NAME} ${APP}/${CRATE_NAME}

RUN chmod +x ${APP}/bostil-bot
WORKDIR ${APP}
RUN chmod +x ./${CRATE_NAME}

CMD [ "./bostil-bot" ]
CMD [ "./${CRATE_NAME}" ]
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ Created for fun and to learn more about the Rust language.

## Roadmap

### Moderação
### Moderation

- [ ] Clear messages
- [ ] Ban
- [ ] Kick

### Utilidades
### Utils

- [ ] Create a poll
- [-] Create a poll
- [x] Create a poll with buttons
- [ ] With timer
- [ ] Welcome message

### Diversão
### Fun

- [ ] Detect user activities to send messages
- [-] Play music
Expand All @@ -73,9 +75,10 @@ Created for fun and to learn more about the Rust language.
- [x] Radio [94 FM][94-fm-url]
- [x] Radio [89 FM][89-fm-url]
- [x] Radio [88.3 FM][perderneiras-fm-url]
- [ ] Add noise to the audio (like a radio)
- [x] Add noise to the audio (like a radio)
- [ ] Recording audio only from a "SCALIZA" user

### Integrações
### Integrations

- [x] [Jukes Box](https://discord.com/api/oauth2/authorize?client_id=716828755003310091&permissions=3271680&scope=applications.commands%20bot)

Expand Down
47 changes: 47 additions & 0 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "bostil-bot"
repository = "https://github.com/kszinhu/bostil-bot"
version = "0.1.0"
description = "Bostil Discord Bot"
authors = { workspace = true }
edition = { workspace = true }

[dependencies]
# Internal crates
bostil-core = { path = "../core" }

# Discord (Main dependencies)
serenity = { workspace = true }
songbird = { workspace = true }
tokio = { features = ["full"], version = "1" }
symphonia = { features = ["aac", "mp3", "isomp4", "alac"], version = "0.5.2" }
reqwest = { version = "0.11", default-features = false, features = [
"blocking",
"json",
"rustls-tls-native-roots",
] }

# Database
uuid = { version = "^1.4.1", features = ["v4", "fast-rng"] }
postgres = { version = "0.19" }
diesel = { version = "2", features = ["postgres", "time", "uuid"] }
diesel_migrations = { version = "2" }
dotenvy = "0.15.7"
time = "0.3"

# Logging
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-futures = { workspace = true }

# Internationalization (yml)
rust-i18n = "*"
serde_yaml = "*"

# Other
lazy_static = { workspace = true }
once_cell = { workspace = true }

# Potentially remove later
nanoid = "0.4"
openssl = { version = "*", features = ["vendored"] }
13 changes: 13 additions & 0 deletions app/diesel.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# For documentation on how to configure this file,
# see https://diesel.rs/guides/configuring-diesel-cli

[print_schema]
file = "src/schema.rs"
custom_type_derives = ["diesel::sql_types::SqlType", "std::fmt::Debug"]
import_types = [
"diesel::sql_types::*",
"crate::modules::core::entities::exports::*",
]

[migrations_directory]
dir = "migrations"
Empty file added app/migrations/.keep
Empty file.
6 changes: 6 additions & 0 deletions app/migrations/00000000000000_diesel_initial_setup/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- This file was automatically created by Diesel to setup helper functions
-- and other internal bookkeeping. This file is safe to edit, any future
-- changes will be added to existing projects as new migrations.

DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
DROP FUNCTION IF EXISTS diesel_set_updated_at();
Loading
Loading