tailly_messages/Dockerfile
2025-08-12 22:16:32 +03:00

46 lines
1.2 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ===== Билдер =====
FROM golang:1.25rc2-alpine AS builder
# Устанавливаем зависимости для сборки
RUN apk add --no-cache git make gcc musl-dev
# Рабочая директория
WORKDIR /build
# Копируем файлы модулей
COPY go.mod go.sum ./
# Скачиваем зависимости
RUN go mod download
# Копируем весь проект
COPY . .
# Собираем бинарник (статически линкованный)
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-w -s -extldflags '-static'" \
-o /app/server \
./server.go
# ===== Финальный образ =====
FROM alpine:3.19
# Устанавливаем tzdata для работы с временными зонами
RUN apk add --no-cache tzdata ca-certificates && \
update-ca-certificates
# Копируем бинарник
COPY --from=builder /app/server /usr/local/bin/server
# Копируем .env если нужен
# COPY --from=builder /build/.env /app/.env
# Настройки среды
ENV GIN_MODE=release \
PORT=50051
# Открываем порт
EXPOSE $PORT
# Запускаем сервер
CMD ["/usr/local/bin/server"]