From 34d5fddf6c6c4df4c1984354e54ce2cc4ac60fb4 Mon Sep 17 00:00:00 2001 From: jude Date: Sun, 9 Apr 2023 17:35:40 +0100 Subject: [PATCH] Add containerised build instructions --- Cargo.lock | 5 +++-- Cargo.toml | 3 +-- Containerfile | 9 +++++++++ README.md | 17 ++++++++++++++++- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 Containerfile diff --git a/Cargo.lock b/Cargo.lock index ddf7851..9bf61f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2063,8 +2063,9 @@ dependencies = [ [[package]] name = "songbird" -version = "0.3.1" -source = "git+https://github.com/Erk-/songbird?branch=do-not-fail-if-new-opcode#0618112a3353a47b2fcdb4eb327ede1a77a8cda2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f686a0fd771939de1da3e43cee45169fafe1595770b94680572cf18bdef288" dependencies = [ "async-trait", "async-tungstenite", diff --git a/Cargo.toml b/Cargo.toml index c4810b8..b1f9e7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,7 @@ authors = ["jellywx "] edition = "2018" [dependencies] -songbird = { git = "https://github.com/Erk-/songbird", branch = "do-not-fail-if-new-opcode", features = ["builtin-queue"] } -# songbird = { version = "0.3", features = ["builtin-queue"] } +songbird = { version = "0.3", features = ["builtin-queue"] } poise = "0.3" sqlx = { version = "0.5", default-features = false, features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "migrate"] } tokio = { version = "1", features = ["fs", "process", "io-util"] } diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..d23ffee --- /dev/null +++ b/Containerfile @@ -0,0 +1,9 @@ +FROM ubuntu:20.04 + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y gcc gcc-multilib cmake ffmpeg libopus-dev 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 cargo install cargo-deb diff --git a/README.md b/README.md index acc466e..db0d5b8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ Options: ## Building from source +When running from source, the config options above can be configured simply as environment variables. + +Two options for building are offered. The first is easier. + +### Build for local platform + 1. Install build dependencies: `sudo apt install gcc gcc-multilib cmake ffmpeg libopus-dev pkg-config libssl-dev` 2. Install database server: `sudo apt install mysql-server-8.0`. Create a database called `soundfx` 3. Install Cargo and Rust from https://rustup.rs @@ -30,4 +36,13 @@ Options: 5. From the source code directory, execute `sqlx migrate run` 6. Build with cargo: `cargo build --release` -When running from source, the config options above can be configured simply as environment variables. +### Build for other platform + +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. + +1. Install container software: `sudo apt install podman`. +2. Install database server: `sudo apt install mysql-server-8.0`. Create a database called `soundfx` +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 soundfx .` +6. Build with podman: `podman run --rm --network=host -v "$PWD":/mnt -w /mnt -e "DATABASE_URL=mysql://user@localhost/soundfx" soundfx cargo deb`