Skip to content

Commit

Permalink
build(dockerfile): change runtime stage image
Browse files Browse the repository at this point in the history
Segmentation fault on alpine - (Lakelezz/audiopus_sys#9)
  • Loading branch information
kszinhu committed Aug 1, 2023
1 parent 5844972 commit 61e31eb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
26 changes: 14 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#----------------
# Build stage
#----------------
FROM rust:1.70.0-alpine3.17 as builder
FROM rust:1.71.0-alpine3.17 as builder

# System dependencies, update pkg-config and libssl-dev
RUN apk add --no-cache \
build-base \
musl-dev \
curl \
ffmpeg \
youtube-dl \
pkgconfig \
openssl-dev \
opus \
opus-dev \
git

Expand All @@ -23,16 +26,14 @@ COPY Cargo.toml ./Cargo.toml
COPY public ./public
COPY src ./src

# Build the dependencies
RUN cargo clean
RUN cargo build --release

# Remove the source code
RUN rm src/**/*.rs
# Build and cache the dependencies
RUN cargo fetch \
&& cargo build --release \
&& rm src/**/*.rs

ADD . ./

# Remove the target directory
# Remove the target dependencies
RUN rm ./target/release/deps/bostil_bot*

# Build the application
Expand All @@ -41,14 +42,15 @@ RUN cargo build --release
#----------------
# Runtime stage
#----------------
FROM alpine:latest AS runtime
FROM ubuntu:22.04 as runtime

ARG APP=/usr/src/app

# System dependencies
RUN apk add --no-cache ca-certificates tzdata ffmpeg opus-dev curl \
&& curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl \
&& chmod a+rx /usr/local/bin/youtube-dl
# RUN apk add --no-cache musl-dev libgcc ca-certificates tzdata ffmpeg youtube-dl opus opus-dev curl
RUN apt update \
&& apt install ffmpeg youtube-dl libopus-dev ca-certificates -y \
&& rm -r /var/cache/apt

# Copy the binary from the builder stage
COPY --from=builder /usr/src/app/bostil-bot/target/release/bostil-bot ${APP}/bostil-bot
Expand Down
3 changes: 3 additions & 0 deletions public/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ commands:
reply: tuned in %{radio_name}
user_not_connected: You aren't connected to any voice channel
voice:
join_failed: Crap! I couldn't connect
user_not_connected: You aren't connected to any voice channel
bot_not_connected: I'm not connected on any voice channel
join: Good morning TCHURMA
mute: Silence
un_mute: Shine's again
Expand Down
1 change: 1 addition & 0 deletions public/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ commands:
reply: Tá na sintonia da rádio %{radio_name}
user_not_connected: Você não está conectado em nenhum canal de voz
voice:
join_failed: Não consegui entrar no canal de voz
user_not_connected: Você não está conectado em nenhum canal de voz
bot_not_connected: Eu não estou conectado em nenhum canal de voz
join: Tenho até amigos que são, ...ops\nBom dia turma
Expand Down
21 changes: 19 additions & 2 deletions src/events/voice.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::internal::debug::{log_message, STATUS_ERROR};
use crate::internal::debug::{log_message, STATUS_ERROR, STATUS_INFO};

use rust_i18n::t;

Expand All @@ -18,12 +18,29 @@ pub async fn join(ctx: &Context, guild: &Guild, user_id: &UserId) -> CommandResu
}
};

println!("Connecting to {:?}", connect_to);

let manager = songbird::get(ctx)
.await
.expect("Songbird Voice client placed in at initialisation.")
.clone();

let _handler = manager.join(guild.id, connect_to).await;
println!("Manager: {:?}", manager);

let handler = manager.join(guild.id, connect_to).await;

println!("Handler: {:?}", handler);

match handler.1 {
Ok(_) => {}
Err(why) => {
log_message(&format!("Failed: {:?}", why), &STATUS_ERROR);

return Ok(t!("commands.voice.join_failed"));
}
}

log_message(&format!("Joined voice channel"), &STATUS_INFO);

Ok(t!("commands.voice.join"))
}
Expand Down

0 comments on commit 61e31eb

Please sign in to comment.