Files
webtransport_test/Dockerfile
2026-04-04 15:24:45 +00:00

42 lines
1.2 KiB
Docker
Raw Permalink 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.

# ЭТАП 1: Сборка
FROM golang:1.21-alpine AS builder
# Устанавливаем git, так как go mod tidy может его потребовать
RUN apk add --no-cache git
WORKDIR /build
# Копируем только go.mod (если go.sum нет, это не страшно)
COPY go.mod ./
# Если go.sum существует локально, он подхватится, если нет — пропустится
COPY go.sum* ./
# Копируем исходный код
COPY . .
# ВЫПОЛНЯЕМ TIDY ПЕРЕД СБОРКОЙ
# Это создаст/обновит go.sum внутри контейнера
RUN go mod tidy
# Собираем бинарник
RUN CGO_ENABLED=0 GOOS=linux go build -o /app-binary main.go
# ЭТАП 2: Финальный образ
FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata
# Указываем рабочую директорию
WORKDIR /root/
# Копируем бинарник
COPY --from=builder /app-binary .
# КОПИРУЕМ HTML ФАЙЛ (добавь эту строку)
COPY index.html .
# Открываем порт
EXPOSE 8080
# Запускаем
CMD ["./app-binary"]