Skip to content

Commit

Permalink
feat(core): remember IP per service for forwards on supported platforms
Browse files Browse the repository at this point in the history
Unfortunately macOS does not support binding to local addresses other
than 127.0.0.1 without explicit aliasing which requires sudo privileges.
Other platforms and Linux setups may have this limitation as well, so
we gracefully fall back when we're not allowed to bind to our preferred
addresses.

This is a fairly low-key feature in and of itself, but includes the
major addition of a user-wide SQlite database, which we can use for a
number of other things. The PR includes the basic setup to build
features that leverage persistent local state, and through the ORM we
can later consider supporting other types of databases.
  • Loading branch information
edvald committed Dec 28, 2019
1 parent 120444e commit f7587c3
Show file tree
Hide file tree
Showing 12 changed files with 805 additions and 91 deletions.
53 changes: 35 additions & 18 deletions garden-service/bin/build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ echo "Packaging version ${version}-${commit_hash}"

echo "-> Copying files to tmp build dir..."
mkdir -p dist
dist_path=$(cd dist && pwd)
rm -rf tmp/dist
mkdir -p tmp/dist
tmp_dist_path=$(cd tmp/dist && pwd)
mkdir tmp/dist/bin
mkdir tmp/dist/build

Expand All @@ -49,42 +51,57 @@ echo "-> Preparing packages..."
cd dist

echo " -> linux-amd64"
pkg --target node12-linux-x64 ../tmp/dist
pkg --target node12-linux-x64 ${tmp_dist_path}
rm -rf linux-amd64
mkdir linux-amd64
target_path=$(cd linux-amd64 && pwd)

mv garden-service linux-amd64/garden
cp -r ../tmp/dist/static linux-amd64
cp -r ${tmp_dist_path}/static ${target_path}

echo " -> binary dependencies"
# fetch and copy sqlite binary
cd ${garden_service_root}/node_modules/sqlite3
node-pre-gyp install --target_arch=x64 --target_platform=linux
cp lib/binding/node-v72-linux-x64/node_sqlite3.node ${target_path}
cd ${dist_path}
echo " -> tar"
tar -czf garden-${version}-linux-amd64.tar.gz linux-amd64

echo " -> alpine-amd64"
pkg --target node12-alpine-x64 ../tmp/dist
rm -rf alpine-amd64
mkdir alpine-amd64
mv garden-service alpine-amd64/garden
cp -r ../tmp/dist/static alpine-amd64
echo " -> tar"
tar -czf garden-${version}-alpine-amd64.tar.gz alpine-amd64

echo " -> windows-amd64"
pkg --target node12-win-x64 ../tmp/dist
pkg --target node12-win-x64 ${tmp_dist_path}
rm -rf windows-amd64
mkdir windows-amd64
target_path=$(cd windows-amd64 && pwd)
# Name should match go release and other standards using full "windows" name
mv garden-service.exe windows-amd64/garden.exe
cp -r ../tmp/dist/static windows-amd64
cp -r ${tmp_dist_path}/static ${target_path}

echo " -> binary dependencies"
# fetch and copy sqlite binary
cd ${garden_service_root}/node_modules/sqlite3
node-pre-gyp install --target_arch=x64 --target_platform=win32
cp lib/binding/node-v72-win32-x64/node_sqlite3.node ${target_path}
cd ${dist_path}
echo " -> zip"
zip -q -r garden-${version}-windows-amd64.zip windows-amd64

echo " -> macos-amd64"
rm -rf macos-amd64
mkdir macos-amd64
pkg --target node12-macos-x64 ../tmp/dist
target_path=$(cd macos-amd64 && pwd)
pkg --target node12-macos-x64 ${tmp_dist_path}
mv garden-service macos-amd64/garden
cp -r ../tmp/dist/static macos-amd64

# need to include the .node binary for fsevents
cp ../lib/fsevents/node-v72-darwin-x64/fse.node macos-amd64/fse.node
cp -r ${tmp_dist_path}/static ${target_path}

echo " -> binary dependencies"
# fetch and copy sqlite binary
cd ${garden_service_root}/node_modules/sqlite3
node-pre-gyp install --target_arch=x64 --target_platform=darwin
cp lib/binding/node-v72-darwin-x64/node_sqlite3.node ${target_path}
cd ${dist_path}
# include the .node binary for fsevents
cp ${garden_service_root}/lib/fsevents/node-v72-darwin-x64/fse.node macos-amd64/fse.node

echo " -> tar"
tar -czf garden-${version}-macos-amd64.tar.gz macos-amd64
Loading

0 comments on commit f7587c3

Please sign in to comment.