-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from TKYcraft/issue#9,14
Issue#9,14 複数ギルドの対応および音声がバグる問題の修正
- Loading branch information
Showing
3 changed files
with
128 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.DS_Store | ||
.env | ||
app/file/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,52 @@ | ||
# ビルド用の環境 | ||
FROM golang:1.18-alpine as builder | ||
|
||
# go installにgitを使っているようなのでadd | ||
RUN apk update && apk --no-cache add git | ||
# go getにgit、glibcが必要となるためmusl-dev、cgoの関係でgccを使っているようなのでadd | ||
RUN apk update && apk --no-cache add git gcc musl-dev | ||
|
||
# ディレクトリの作成 | ||
RUN mkdir -p /go_usr/app/src /go_usr/app/build | ||
RUN mkdir -p /go_usr/app/src /go_usr/app/build /go_usr/app/pkg | ||
|
||
# ワーキングディレクトリの設定 | ||
WORKDIR /go_usr/app | ||
|
||
RUN go mod init TKYcraft/tsuru-run | ||
|
||
# ワーキングディレクトリの設定 | ||
WORKDIR /go_usr/app/pkg | ||
|
||
# ffmpegのダウンロードと解凍 | ||
RUN wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz && \ | ||
tar xvf ffmpeg-git-amd64-static.tar.xz && \ | ||
cp -rpf $(ls -d ffmpeg-git*static/) /go_usr/app/pkg/ffmpeg | ||
|
||
# 使用しているパッケージのインストール | ||
RUN --mount=type=cache,target=${GOPATH}/src \ | ||
go get github.com/bwmarrin/discordgo | ||
# RUN go get github.com/bwmarrin/dgvoice | ||
go get \ | ||
github.com/bwmarrin/discordgo \ | ||
github.com/bwmarrin/dgvoice \ | ||
layeh.com/gopus | ||
|
||
# ホストのファイルをコンテナの作業ディレクトリに移行 | ||
COPY ./app/src /go_usr/app/src | ||
|
||
# ワーキングディレクトリの設定 | ||
WORKDIR /go_usr/app | ||
|
||
# buildを超えてキャッシュを保持し、ファイルが変更されていなければキャッシュの利用ができる | ||
RUN --mount=type=cache,target=/.cache/go-build \ | ||
CGO_ENABLED=0 \ | ||
go build -installsuffix cgo -o build/main.build src/main.go | ||
CGO_ENABLED=1 \ | ||
# スタティックリンクにすることでバイナリのみで動作するように変更 | ||
go build -ldflags '-s -w -extldflags=-static' -o build/main.build src/main.go | ||
|
||
# 実行ファイルのみの環境 | ||
FROM gcr.io/distroless/static as dev | ||
|
||
COPY ./app/file /go_usr/file | ||
|
||
# ビルド用の環境から実行ファイルをコピー | ||
COPY --from=builder /go_usr/app/build/main.build /go_usr/app/build/main.build | ||
COPY --from=builder /go_usr/app/pkg/ffmpeg/ffmpeg /usr/bin/ffmpeg | ||
COPY --from=builder /go_usr/app/build /go_usr/app/build | ||
|
||
# 実行 | ||
ENTRYPOINT [ "/go_usr/app/build/main.build" ] |