Skip to content

Commit

Permalink
fix: build alpine binary inside an alpine container
Browse files Browse the repository at this point in the history
This is needed as building a node10 alpine binary on a linux platform generates a bad binary which segfaults. Reason is unclear, this is a workaround.
  • Loading branch information
Anton Drukh committed Jul 20, 2019
1 parent a7c6001 commit 7a6afde
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
"prepare": [
"@semantic-release/npm",
{
"//": "build the alpine, macos, linux and windows binaries",
"//": "build the alpine binaries inside an alpine container",
"path": "@semantic-release/exec",
"cmd": "npm i -g pkg && pkg . -t node8-alpine-x64,node8-linux-x64,node8-macos-x64,node8-win-x64"
"cmd": "docker run --rm -i -v `pwd`:/snyk node:alpine /snyk/scripts/build_alpine_binary.sh"
},
{
"//": "build the macos, linux and windows binaries",
"path": "@semantic-release/exec",
"cmd": "npm i -g pkg && pkg . -t node8-linux-x64,node8-macos-x64,node8-win-x64"
},
{
"//": "shasum all binaries",
Expand Down
19 changes: 19 additions & 0 deletions scripts/build_alpine_binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# echo commands for debug purposes
set -x
# bail out in case of a single command failure
set -e

# this script is expected to run inside a node:alpine docker container
# with the path /snyk mounted with the project folder
cd /snyk
npm install # install deps in case they are missing
npm run prepare # explicit, as running as root would skip scripts

# build the binary
npm i -g pkg
pkg . -t node10-alpine-x64 -o snyk-alpine

# test it for validity
./snyk-alpine -v

0 comments on commit 7a6afde

Please sign in to comment.