Created
April 19, 2025 05:50
-
-
Save Hammer2900/a4acb88ad98af487d6437fcbb063306e to your computer and use it in GitHub Desktop.
compile go to arm64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Этап 1: Сборка приложения | |
FROM golang:latest AS builder | |
# Создаем директорию для исходников | |
RUN mkdir /src | |
WORKDIR /src | |
# Клонируем репозиторий в текущую директорию (/src) | |
RUN git clone --depth 1 https://github.com/aculix/bitplay.git . | |
# Отладка: Смотрим структуру проекта | |
RUN echo "Содержимое /src после клонирования:" && ls -la /src | |
# Загружаем зависимости модуля | |
RUN go mod download | |
# Устанавливаем переменные окружения для кросс-компиляции | |
ENV GOOS=linux | |
ENV GOARCH=arm64 | |
ENV CGO_ENABLED=0 | |
# Собираем приложение из main.go, который находится в корне проекта | |
RUN go build -ldflags="-s -w" -o /bitplay_arm64 . | |
# Проверка создания бинарника | |
RUN ls -la /bitplay_arm64 | |
# Этап 2: Создание минимального образа (если нужен контейнер) | |
# FROM scratch | |
# COPY --from=builder /bitplay_arm64 /bitplay | |
# ENTRYPOINT ["/bitplay"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo docker build --no-cache -t bitplay-builder-hardcoded . | |
mkdir -p ./output_arm64 | |
sudo docker run --rm \ | |
-v "$(pwd)/output_arm64:/host_output" \ | |
bitplay-builder-hardcoded \ | |
cp /bitplay_arm64 /host_output/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment