Skip to content

Commit

Permalink
feat(platforms): add alpine support
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen committed Jun 10, 2020
1 parent 5f4eb61 commit 31c2f67
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.git/
.github/
.idea/
prisma-client-go
*.db
*.sqlite
Expand All @@ -8,6 +9,5 @@ prisma-client-go
schema.graphql
**migrations**/
**/prisma-*
**/query-engine-*
build/
.graphqlconfig
15 changes: 12 additions & 3 deletions binaries/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func BinaryPlatformName() string {
}

distro := getLinuxDistro()

if distro == "alpine" {
return "linux-musl"
}

ssl := getOpenSSL()

name := fmt.Sprintf("%s-openssl-%s", distro, ssl)
Expand Down Expand Up @@ -59,11 +64,11 @@ func checkForExtension(platform string, path string) string {
func getLinuxDistro() string {
out, _ := exec.Command("cat", "/etc/os-release").CombinedOutput()

if out == nil {
return "debian"
if out != nil {
return parseLinuxDistro(string(out))
}

return parseLinuxDistro(string(out))
return "debian"
}

func parseLinuxDistro(str string) string {
Expand All @@ -82,6 +87,10 @@ func parseLinuxDistro(str string) string {
idLike = idLikeMatches[1]
}

if id == "alpine" {
return "alpine"
}

if strings.Contains(idLike, "centos") ||
strings.Contains(idLike, "fedora") ||
strings.Contains(idLike, "rhel") ||
Expand Down
5 changes: 2 additions & 3 deletions docker/integration.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ RUN cd test/integration/; go run github.com/prisma/prisma-client-go migrate up -
RUN cd test/integration/; go run github.com/prisma/prisma-client-go generate

# build the integration binary with all dependencies
RUN cd test/integration/; go build -o /app/main .
RUN cd test/integration/; CGO_ENABLED=0 go build --ldflags '-w -linkmode external -extldflags "-static"' -o /app/main .

# start a new stage to test if the runtime fetching works
FROM golang:1.13
# TODO try scratch image. golang is used because it's available on both linux and windows
FROM alpine

WORKDIR /app

Expand Down

0 comments on commit 31c2f67

Please sign in to comment.