-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (53 loc) · 2 KB
/
Dockerfile
File metadata and controls
77 lines (53 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM golang:1.26.1-bookworm@sha256:ab3d6955bbc813a0f3fdf220c1d817dd89c0b3f283777db8ece4a32fe7858edd AS builder
WORKDIR /app
# Go modulesを有効にする
ENV GO111MODULE=on
# go.modとgo.sumをコピー
COPY go.mod go.sum ./
# 依存関係をダウンロード
RUN go mod download
# ソースコードをコピー
COPY "cmd/health_check" "cmd/health_check"
COPY "cmd/misskey_bot" "cmd/misskey_bot"
COPY "cmd/mixi2_bot" "cmd/mixi2_bot"
COPY lib lib
# アプリケーションをビルド
ENV CGO_ENABLED=0
ENV GOOS=linux
RUN go build -a -installsuffix cgo -o hato-bot-go-misskey-bot cmd/misskey_bot/main.go && \
go build -a -installsuffix cgo -o hato-bot-go-mixi2-bot cmd/mixi2_bot/main.go && \
go build -a -installsuffix cgo -o health-check cmd/health_check/main.go
# 開発用イメージ
FROM builder AS dev
# airをインストール
# hadolint ignore=DL3062
RUN go install github.com/air-verse/air
# air設定ファイルをコピー
COPY .air.toml .
# ポートを公開(必要に応じて)
EXPOSE 8080
# airで実行
CMD ["air", "-c", ".air.toml"]
# 実行用の最小イメージ
FROM scratch AS prod
# CA証明書をコピー(HTTPS接続用)
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# タイムゾーンデータをコピー
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# ビルドした実行ファイルをコピー
COPY --from=builder /app/health-check /health-check
# nonrootユーザーで実行(UID 65534)
USER 65534:65534
# ポートを公開(必要に応じて)
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=40s CMD ./health-check
FROM prod AS prod_misskey
# ビルドした実行ファイルをコピー
COPY --from=builder /app/hato-bot-go-misskey-bot /hato-bot-go-misskey-bot
# 実行
CMD ["./hato-bot-go-misskey-bot"]
FROM prod AS prod_mixi2
# ビルドした実行ファイルをコピー
COPY --from=builder /app/hato-bot-go-mixi2-bot /hato-bot-go-mixi2-bot
# 実行
CMD ["./hato-bot-go-mixi2-bot"]