From bb2519bdabcb053deb9df860748e62d0ad35a4d2 Mon Sep 17 00:00:00 2001 From: Edward Loveall Date: Fri, 22 Dec 2023 10:56:35 -0500 Subject: [PATCH] Add command to build_static Uploading the object file and linking it on the server wasn't working. So I'm now using a statically linked binary. I followed the instructions here: https://crystal-lang.org/reference/1.10/guides/static_linking.html#linux --- script/build_static | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 script/build_static diff --git a/script/build_static b/script/build_static new file mode 100755 index 0000000..438cf82 --- /dev/null +++ b/script/build_static @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Exit if any subcommand fails +set -e +set -o pipefail + +todays_date=$(date "+%Y-%m-%d") +if ! git show HEAD:src/version.cr | rg -q $todays_date; then + echo "Date in committed src/version.cr is not today's date ($todays_date)" + echo "Make sure that the file is both up to date and commited to git." + echo + echo "## src/version.cr" + git show HEAD:src/version.cr + # exit 1 +fi + +# Via: https://crystal-lang.org/reference/1.10/guides/static_linking.html#linux + +~/.docker/bin/docker run --rm -it -v $(pwd):/workspace -w /workspace crystallang/crystal:latest-alpine \ + crystal build src/start_server.cr -o ubuntu_server --static --release