|
1 | | -# escape=` |
| 1 | +FROM golang:1.17.2-windowsservercore-1809 as builder |
2 | 2 |
|
3 | | -FROM brigadecore/win-go-tools:v0.2.0 as builder |
| 3 | +ARG VERSION |
| 4 | +ARG COMMIT |
| 5 | +ENV CGO_ENABLED=0 |
4 | 6 |
|
5 | | -# As of this writing, pacman installs a newer libgit2 than we are able to use. |
6 | | -# Here, we download and install an older version. |
7 | | -RUN curl ` |
8 | | - -L ` |
9 | | - https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-libgit2-1.2.0-3-any.pkg.tar.zst ` |
10 | | - -o C:\windows\temp/libgit2.pkg.tar.zst ` |
11 | | - && bash -l -c "pacman --noconfirm -U /c/windows/temp/libgit2.pkg.tar.zst" |
| 7 | +WORKDIR /src |
| 8 | +COPY sdk/ sdk/ |
| 9 | +WORKDIR /src/v2 |
| 10 | +COPY v2/git-initializer/ git-initializer/ |
| 11 | +COPY v2/internal/ internal/ |
| 12 | +COPY v2/go.mod go.mod |
| 13 | +COPY v2/go.sum go.sum |
12 | 14 |
|
13 | | -WORKDIR C:\\msys64\\brigade |
14 | | -COPY sdk\\ sdk\\ |
15 | | -WORKDIR C:\\msys64\\brigade\\v2 |
16 | | -COPY v2\\go.mod go.mod |
17 | | -COPY v2\\go.sum go.sum |
18 | | -RUN bash -l -c " ` |
19 | | - cd /brigade/v2 ` |
20 | | - && PATH=$PATH:/mingw64/bin ` |
21 | | - GOROOT=/mingw64/lib/go ` |
22 | | - go mod download ` |
23 | | - " |
24 | | -COPY v2\\git-initializer\\ git-initializer\\ |
25 | | -COPY v2\\internal\\ internal\\ |
| 15 | +RUN go build \ |
| 16 | + -o ../bin/git-initializer.exe \ |
| 17 | + -ldflags \"-w -X github.com/brigadecore/brigade-foundations/version.version=$env:VERSION -X github.com/brigadecore/brigade-foundations/version.commit=$env:COMMIT\" \ |
| 18 | + ./git-initializer |
26 | 19 |
|
27 | | -# The `-tags static,system_libgit2` specified below instruct git2go on how to |
28 | | -# locate libgit2. It does NOT imply our binary is statically linked -- in fact, |
29 | | -# it is not. In theory, that can be accomplished by including |
30 | | -# `-extldflags 'static'` in the `-ldflags`, but we've had no luck getting that |
31 | | -# to work. |
32 | | -RUN bash -l -c " ` |
33 | | - cd /brigade/v2 ` |
34 | | - && PATH=$PATH:/mingw64/bin ` |
35 | | - GOROOT=/mingw64/lib/go ` |
36 | | - go build ` |
37 | | - -tags static,system_libgit2 ` |
38 | | - -ldflags \"-w -X github.com/brigadecore/brigade-foundations/version.version=$VERSION -X github.com/brigadecore/brigade-foundations/version.commit=$COMMIT\" ` |
39 | | - -o ../bin/git-initializer.exe ` |
40 | | - ./git-initializer ` |
41 | | - " |
| 20 | +FROM mcr.microsoft.com/windows/nanoserver:1809 |
42 | 21 |
|
43 | | -ENTRYPOINT [ "C:\\msys64\\brigade\\bin\\git-initializer.exe" ] |
| 22 | +COPY --from=builder /src/bin/ /brigade/bin/ |
44 | 23 |
|
45 | | -FROM mcr.microsoft.com/windows/nanoserver:1809 AS final |
46 | | - |
47 | | -USER ContainerAdministrator |
48 | | - |
49 | | -# Note that because we were unable to produce a statically-linked binary, we |
50 | | -# depend on a number of .dlls from the builder image, so we just copy them |
51 | | -# all over and add them to the path. |
52 | | -COPY --from=builder C:\\msys64\\mingw64\\bin\\ C:\\mingw64\\bin\\ |
53 | | -RUN setx /M PATH "%PATH%;C:\mingw64\bin" |
54 | | - |
55 | | -COPY --from=builder C:\\msys64\\brigade\\bin\\ C:\\brigade\\bin\\ |
56 | | - |
57 | | -USER ContainerUser |
58 | | - |
59 | | -ENTRYPOINT ["C:\\brigade\\bin\\git-initializer.exe"] |
| 24 | +ENTRYPOINT ["/brigade/bin/git-initializer.exe"] |
0 commit comments