Add Dockerfile for Coolify deploy
Multi-stage Go build; BOT_TOKEN via environment, not image.
This commit is contained in:
parent
973c19f148
commit
6e9e0bd1ad
3 changed files with 35 additions and 0 deletions
5
.dockerignore
Normal file
5
.dockerignore
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
.git
|
||||||
|
.env
|
||||||
|
*.md
|
||||||
|
Dockerfile*
|
||||||
|
.dockerignore
|
||||||
1
.env.example
Normal file
1
.env.example
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
BOT_TOKEN=123456:replace_me
|
||||||
29
Dockerfile
Normal file
29
Dockerfile
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# === Этап 1: сборка ===
|
||||||
|
# Берём образ с компилятором Go, собираем бинарник.
|
||||||
|
FROM golang:1.26-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Сначала зависимости (кэш Docker не пересобирает их без изменений go.mod)
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Потом код
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Статичный бинарник без CGO — удобно класть в маленький alpine
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/bot .
|
||||||
|
|
||||||
|
# === Этап 2: запуск ===
|
||||||
|
# Лёгкий образ только с бинарником (без компилятора).
|
||||||
|
FROM alpine:3.22
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /out/bot /app/bot
|
||||||
|
|
||||||
|
# Токен НЕ кладём в образ — Coolify передаст BOT_TOKEN как env
|
||||||
|
ENV BOT_TOKEN=
|
||||||
|
|
||||||
|
CMD ["/app/bot"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue