前提
Golang 1.19でDiscordgoを用い、DiscordのBotを作成
実現したいこと
Golang (Discordgo) + Dockerで、Discordのボット用いボイスチャンネルで音声ファイルを再生したいが、linux/arm64/v8 用のビルド過程で Opus が見つからずエラーが出る。
発生している問題・エラーメッセージ
PS C:\xxxx> docker buildx build . -t xxxx/xxxx:xxx --platform linux/arm64/v8 [+] Building 359.2s (15/15) FINISHED => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 362B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/golang:1.19 2.1s => [auth] library/golang:pull token for registry-1.docker.io 0.0s => [ 1/10] FROM docker.io/library/golang:1.19@sha256:xxxxxx 0.0s => [internal] load build context 0.3s => => transferring context: 176.35kB 0.3s => CACHED [ 2/10] RUN mkdir /app 0.0s => [ 3/10] COPY . /app 1.2s => [ 4/10] WORKDIR /app 0.1s => [ 5/10] RUN apt update -y && apt upgrade -y 38.5s => [ 6/10] RUN apt-get install build-essential -y 24.6s => [ 7/10] RUN apt install ffmpeg -y 234.9s => [ 8/10] RUN apt install libopus0 opus-tools -y 15.2s => [ 9/10] RUN go mod download 6.3s => ERROR [10/10] RUN go build -o bot ./cmd/bot/ 35.8s ------ > [10/10] RUN go build -o bot ./cmd/bot/: #0 7.812 # pkg-config --cflags -- opus #0 7.812 Package opus was not found in the pkg-config search path. #0 7.812 Perhaps you should add the directory containing `opus.pc' #0 7.812 to the PKG_CONFIG_PATH environment variable #0 7.812 No package 'opus' found #0 7.812 pkg-config: exit status 1 ------ error: failed to solve: executor failed running [/bin/sh -c go build -o bot ./cmd/bot/]: exit code: 2
該当のソースコード
Dockerfile
1FROM golang:1.19 2 3RUN mkdir /app 4COPY . /app 5WORKDIR /app 6 7RUN apt update -y && apt upgrade -y 8RUN apt-get install build-essential -y 9RUN apt install ffmpeg -y 10RUN apt install libopus0 opus-tools -y 11 12RUN go mod download 13 14RUN go build -o bot ./cmd/bot/ 15 16CMD ["./bot"]
試したこと
今回エラーが発生する条件として、 Raspberrypi 4 Model B 8G (arm64/v8)用へ以下のコマンド使用しビルドしたときにエラーが発生する。
console
1docker buildx build . -t xxxx/xxxx:xxx --platform linux/arm64/v8
因みにWindows 10 Docker Desktopで用いる為に以下のコマンドでビルドした場合はエラーが発生せず、Discord内のボイスチャンネルで音声ファイルを再生することができた。
console
1docker build -t xxxx/xxxx:xxx .
補足情報(FW/ツールのバージョンなど)
go.mod
Go
1module main 2 3go 1.19 4 5require ( 6 github.com/PuerkitoBio/goquery v1.8.0 // indirect 7 github.com/andybalholm/cascadia v1.3.1 // indirect 8 github.com/bwmarrin/dgvoice v0.0.0-20210225172318-caaac756e02e // indirect 9 github.com/bwmarrin/discordgo v0.26.0 // indirect 10 github.com/fatih/color v1.13.0 // indirect 11 github.com/gorilla/websocket v1.4.2 // indirect 12 github.com/joho/godotenv v1.4.0 // indirect 13 github.com/mattn/go-colorable v0.1.9 // indirect 14 github.com/mattn/go-isatty v0.0.14 // indirect 15 golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect 16 golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect 17 golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect 18 layeh.com/gopus v0.0.0-20210501142526-1ee02d434e32 // indirect 19)
以下二つのライブラリを主に用い、ボットを作成しています。
https://github.com/bwmarrin/discordgo
https://github.com/bwmarrin/dgvoice
あなたの回答
tips
プレビュー