Skip to content

Instantly share code, notes, and snippets.

@juev
Created March 20, 2025 09:28
Show Gist options
  • Save juev/82f68fcc7f82af70da2f9b9c3debf74e to your computer and use it in GitHub Desktop.
Save juev/82f68fcc7f82af70da2f9b9c3debf74e to your computer and use it in GitHub Desktop.

Сборка образа golang приложений

Реализуется через обычный мультистейдж, образ с golang, в котором собирается приложение и затем готовый бинарник копируется в дистролесс образ.

Пример:

FROM golang AS build
WORKDIR /src
RUN GOBIN=/src go install github.com/nkanaev/yarr/cmd/yarr@latest

FROM gcr.io/distroless/base-debian12:latest
COPY --from=build /src/yarr /usr/local/bin/yarr
EXPOSE 7070
CMD ["/usr/local/bin/yarr", "-addr", "0.0.0.0:7070", "-db", "/data/yarr.db"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment