Change default Python location. Update build instructions. Add container build instructions
This commit is contained in:
parent
98191d29ee
commit
734a39a001
@ -41,7 +41,8 @@ maintainer-scripts = "debian"
|
|||||||
assets = [
|
assets = [
|
||||||
["target/release/reminder-rs", "usr/bin/reminder-rs", "755"],
|
["target/release/reminder-rs", "usr/bin/reminder-rs", "755"],
|
||||||
["conf/default.env", "etc/reminder-rs/default.env", "600"],
|
["conf/default.env", "etc/reminder-rs/default.env", "600"],
|
||||||
# ["web/static/", "var/www/reminder-rs/static", "755"],
|
["web/static/**/*", "var/www/reminder-rs/static", "755"],
|
||||||
|
["web/templates/**/*", "var/www/reminder-rs/templates", "755"],
|
||||||
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
|
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5,5 +5,5 @@ ENV RUSTUP_HOME=/usr/local/rustup \
|
|||||||
PATH=/usr/local/cargo/bin:$PATH
|
PATH=/usr/local/cargo/bin:$PATH
|
||||||
|
|
||||||
RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y gcc gcc-multilib cmake pkg-config libssl-dev curl mysql-client-8.0
|
RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y gcc gcc-multilib cmake pkg-config libssl-dev curl mysql-client-8.0
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain nightly
|
||||||
RUN cargo install cargo-deb
|
RUN cargo install cargo-deb
|
||||||
|
37
README.md
37
README.md
@ -7,30 +7,31 @@ reminders are paid on the hosted version of the bot. Keep reading if you want to
|
|||||||
|
|
||||||
You'll need rustc and cargo for compilation. To run, you'll need Python 3 still (due to no suitable replacement for dateparser in Rust)
|
You'll need rustc and cargo for compilation. To run, you'll need Python 3 still (due to no suitable replacement for dateparser in Rust)
|
||||||
|
|
||||||
### Compiling
|
### Compiling for local target
|
||||||
Install build requirements:
|
1. Install requirements:
|
||||||
`sudo apt install gcc gcc-multilib cmake libssl-dev build-essential python3-dateparser`
|
`sudo apt install gcc gcc-multilib cmake libssl-dev build-essential python3-dateparser`
|
||||||
|
2. Install rustup from https://rustup.rs
|
||||||
Install Rust from https://rustup.rs
|
3. Install the nightly toolchain: `rustup toolchain default nightly`
|
||||||
|
4. Install database server: `sudo apt install mysql-server-8.0`. Create a database called `reminders`.
|
||||||
Reminder Bot can then be built by running `cargo build --release` in the top level directory. It is necessary to create a
|
5. Install `sqlx-cli`: `cargo install sqlx-cli`.
|
||||||
folder called 'assets' containing an image file with its name specified in the environment as `WEBHOOK_AVATAR`, of
|
6. Run migrations: `sqlx migrate run`.
|
||||||
dimensions 128x128px to be used as the webhook avatar.
|
7. Set environment variables:
|
||||||
|
|
||||||
#### Compilation environment variables
|
|
||||||
These environment variables must be provided when compiling the bot
|
|
||||||
* `DATABASE_URL` - the URL of your MySQL database (`mysql://user[:password]@domain/database`)
|
* `DATABASE_URL` - the URL of your MySQL database (`mysql://user[:password]@domain/database`)
|
||||||
* `WEBHOOK_AVATAR` - accepts the name of an image file located in `$CARGO_MANIFEST_DIR/assets/` to be used as the avatar when creating webhooks. **IMPORTANT: image file must be 128x128 or smaller in size**
|
* `WEBHOOK_AVATAR` - accepts the name of an image file located in `$CARGO_MANIFEST_DIR/assets/` to be used as the avatar when creating webhooks. **IMPORTANT: image file must be 128x128 or smaller in size**
|
||||||
|
8. Build: `cargo build --release`
|
||||||
|
|
||||||
### Setting up database
|
### Compiling for other target
|
||||||
Use MySQL 8. MariaDB is confirmed not working at the moment.
|
By default, this builds targeting Ubuntu 20.04. Modify the Containerfile if you wish to target a different platform. These instructions are written using `podman`, but `docker` should work too.
|
||||||
|
|
||||||
Load the SQL files in order from "migrations" to generate the database schema.
|
1. Install container software: `sudo apt install podman`.
|
||||||
|
2. Install database server: `sudo apt install mysql-server-8.0`. Create a database called `reminders`
|
||||||
|
3. Install SQLx CLI: `cargo install sqlx-cli`
|
||||||
|
4. From the source code directory, execute `sqlx migrate run`
|
||||||
|
5. Build container image: `podman build -t reminder-rs .`
|
||||||
|
6. Build with podman: `podman run --rm --network=host -v "$PWD":/mnt -w /mnt -e "DATABASE_URL=mysql://user@localhost/reminders" reminder-rs cargo deb`
|
||||||
|
|
||||||
### Setting up Python
|
|
||||||
Reminder Bot uses `python3-dateparser` to handle dates. This depends on Python 3.
|
|
||||||
|
|
||||||
### Environment Variables
|
### Configuring
|
||||||
Reminder Bot reads a number of environment variables. Some are essential, and others have hardcoded fallbacks. Environment variables can be loaded from a .env file in the working directory.
|
Reminder Bot reads a number of environment variables. Some are essential, and others have hardcoded fallbacks. Environment variables can be loaded from a .env file in the working directory.
|
||||||
|
|
||||||
__Required Variables__
|
__Required Variables__
|
||||||
@ -42,5 +43,5 @@ __Other Variables__
|
|||||||
* `LOCAL_TIMEZONE` - default `UTC`, necessary for calculations in the natural language processor
|
* `LOCAL_TIMEZONE` - default `UTC`, necessary for calculations in the natural language processor
|
||||||
* `SUBSCRIPTION_ROLES` - default `None`, accepts a list of Discord role IDs that are given to subscribed users
|
* `SUBSCRIPTION_ROLES` - default `None`, accepts a list of Discord role IDs that are given to subscribed users
|
||||||
* `CNC_GUILD` - default `None`, accepts a single Discord guild ID for the server that the subscription roles belong to
|
* `CNC_GUILD` - default `None`, accepts a single Discord guild ID for the server that the subscription roles belong to
|
||||||
* `PYTHON_LOCATION` - default `venv/bin/python3`. Can be changed if your Python executable is located somewhere else
|
* `PYTHON_LOCATION` - default `/usr/bin/python3`. Can be changed if your Python executable is located somewhere else
|
||||||
* `THEME_COLOR` - default `8fb677`. Specifies the hex value of the color to use on info message embeds
|
* `THEME_COLOR` - default `8fb677`. Specifies the hex value of the color to use on info message embeds
|
||||||
|
@ -48,5 +48,5 @@ lazy_static! {
|
|||||||
.map_or(THEME_COLOR_FALLBACK, |inner| u32::from_str_radix(&inner, 16)
|
.map_or(THEME_COLOR_FALLBACK, |inner| u32::from_str_radix(&inner, 16)
|
||||||
.unwrap_or(THEME_COLOR_FALLBACK));
|
.unwrap_or(THEME_COLOR_FALLBACK));
|
||||||
pub static ref PYTHON_LOCATION: String =
|
pub static ref PYTHON_LOCATION: String =
|
||||||
env::var("PYTHON_LOCATION").unwrap_or_else(|_| "venv/bin/python3".to_string());
|
env::var("PYTHON_LOCATION").unwrap_or_else(|_| "/usr/bin/python3".to_string());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user