-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM golang:1.22-bookworm AS builder | ||
|
||
WORKDIR /build | ||
|
||
RUN apt update && apt install -y pkg-config cmake | ||
|
||
# Cache modules and git2go build | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
# Build git2go | ||
RUN git clone https://github.com/libgit2/git2go vendor/github.com/libgit2/git2go/v34 | ||
RUN cd vendor/github.com/libgit2/git2go/v34 && git checkout v34.0.0 && git submodule update --init && make install-static | ||
RUN mv vendor/github.com/libgit2/git2go/v34 git2go | ||
|
||
# Copy the code | ||
COPY .git main.go ./ | ||
COPY splitter splitter/ | ||
RUN go mod vendor | ||
RUN rm -rf vendor/github.com/libgit2/git2go/v34 | ||
RUN mv git2go vendor/github.com/libgit2/git2go/v34 | ||
|
||
# Build | ||
RUN go build -tags static -ldflags="-s -w -X 'main.version=$(git describe --tags)'" -o splitsh-lite ./main.go | ||
|
||
# Prepare files for the final image | ||
WORKDIR /dist | ||
RUN cp /build/splitsh-lite ./splitsh-lite | ||
|
||
# Add dependent libraries | ||
RUN ldd splitsh-lite | tr -s '[:blank:]' '\n' | grep '^/' | xargs -I % sh -c 'mkdir -p $(dirname ./%); cp % ./%;' | ||
|
||
# Create the runtime image | ||
FROM scratch | ||
|
||
COPY --from=builder /dist / | ||
ENTRYPOINT ["./splitsh-lite"] |