🚀 chore: add initial project setup with docker, go modules, and basic api structure
Add docker configuration for building and running the application, including a dockerfile and docker-compose.yml. Set up go modules with dependencies and create the basic api structure with main.go, models, and wrapper files. Include .dockerignore and .gitignore files to manage ignored files and directories. Add constants for ipatool path and global flags.
This commit is contained in:
36
docker/Dockerfile
Normal file
36
docker/Dockerfile
Normal file
@ -0,0 +1,36 @@
|
||||
# --- ЭТАП 1: Сборка ---
|
||||
FROM golang:1.23-alpine AS builder
|
||||
|
||||
# Устанавливаем рабочую директорию
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем файлы зависимостей
|
||||
# Это делается отдельно, чтобы Docker кэшировал слои с модулями
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Копируем исходный код
|
||||
COPY . .
|
||||
|
||||
# Собираем бинарный файл
|
||||
# CGO_ENABLED=0 нужен для статической линковки (чтобы работало в пустом образе)
|
||||
# GOOS=linux гарантирует сборку под Linux
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/server main.go
|
||||
|
||||
# --- ЭТАП 2: Запуск ---
|
||||
FROM alpine:latest
|
||||
|
||||
# Устанавливаем часовой пояс и корневые сертификаты (важно для HTTPS запросов)
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем только скомпилированный файл из предыдущего этапа
|
||||
COPY --from=builder /app/server .
|
||||
COPY --from=builder /app/ipatool .
|
||||
|
||||
# Открываем порт (тот же, что в коде Huma)
|
||||
EXPOSE 8888
|
||||
|
||||
# Запускаем приложение
|
||||
CMD ["./server"]
|
||||
Reference in New Issue
Block a user