Files
go_htmx_app/Dockerfile
2026-04-04 17:46:25 +00:00

31 lines
996 B
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.

# ЭТАП 1: Сборка
FROM golang:1.21-alpine AS builder
# Устанавливаем рабочую директорию
WORKDIR /app
# Сначала копируем файлы зависимостей
COPY go.mod ./
COPY go.sum* ./
RUN go mod tidy
# Копируем ВЕСЬ проект (включая папку templates)
COPY . .
# Собираем бинарник
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/
# Копируем бинарник из корня (как указано в -o выше)
COPY --from=builder /app-binary .
# Копируем папку templates из рабочей директории сборщика (/app)
# Обратите внимание: путь должен совпадать с WORKDIR первого этапа
COPY --from=builder /app/template ./template
EXPOSE 8080
CMD ["./app-binary"]