DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

1d41589def1911e4458d03cb0b32f8d7ccdf7b61 — skye 1 year, 7 months ago 7fcf86f
feat: build.sh for client, build in docker for musl
3 files changed, 58 insertions(+), 2 deletions(-)

M Cargo.lock
A client/Dockerfile.alpine
A client/build.sh
M Cargo.lock => Cargo.lock +2 -2
@@ 2456,9 2456,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"

[[package]]
name = "openssl-sys"
version = "0.9.85"
version = "0.9.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0"
checksum = "992bac49bdbab4423199c654a5515bd2a6c6a23bf03f2dd3bdb7e5ae6259bc69"
dependencies = [
 "cc",
 "libc",

A client/Dockerfile.alpine => client/Dockerfile.alpine +9 -0
@@ 0,0 1,9 @@
# For building static executables for musl, mainly for Alpine

FROM rust:1.69.0-alpine3.17

RUN apk update

RUN apk add musl-dev pkgconf \
	openssl-dev


A client/build.sh => client/build.sh +47 -0
@@ 0,0 1,47 @@
#!/bin/bash

function confirm() {
  echo -n "$@ [y/N]: "
    read -e answer
    for response in y Y
    do
        if [ "_$answer" == "_$response" ]
        then
            return 0
        fi
    done

    # default to no
    return 1
}

function buildmusl() {
  # build a docker image with the required libs
  docker build -f Dockerfile.alpine -t laurelinclient-musl-builder .

  # create the target dir
  mkdir ../target

  # use the docker image to build an executable
  docker run --rm --user "$(id -u)":"$(id -g)" \
	  -v "$PWD":/usr/src/client \
	  -v "$PWD/../target":/usr/src/target \
	  -v "$PWD/../Cargo.toml":/usr/src/Cargo.toml \
	  -v "$PWD/../Cargo.lock":/usr/src/Cargo.lock \
	  -v "$PWD/../.cargo":/usr/src/.cargo \
	  -w /usr/src/ \
	  laurelinclient-musl-builder \
	  cargo build --release
}

function buildglibc() {
  cargo build
}

if confirm musl?
then
  buildmusl
else
  buildglibc
fi