Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could someone please show us how to deploy from GitHub Actions #135

Closed
PaulRBerg opened this issue Nov 23, 2023 · 4 comments
Closed

Could someone please show us how to deploy from GitHub Actions #135

PaulRBerg opened this issue Nov 23, 2023 · 4 comments

Comments

@PaulRBerg
Copy link

My colleague @gavriliumircea and I have spent hours debugging our GitHub Actions workflow. We are trying to make it possible to deploy our Rust web server from within an Ubuntu-powered GitHub Action, to no avail.

We've gotten all sorts of errors, all related to the build target. It seems that GitHub is using x86_64-unknown-linux-gnu for their Linux distribution, whereas Vercel is expecting a musl target. Speaking of which, is it not clear why this is a requirement (some additional color in the README would be great).

Could someone give us some guidance, please? An example would be super duper helpful!

Cc @Brendonovich @ecklf @dglsparsons @mike-engel

@dglsparsons
Copy link
Collaborator

Hi @PaulRBerg.

If GitHub is using a different target by default then you will need to install the musl target via rustup, or use a pre-built action that does this for you.

We use musl as this statically links the binary, meaning we do not need specific C libraries available in the Serverless Function runtime.

I'll work on getting you a basic example that deploys via GH Actions 🙏

@dglsparsons
Copy link
Collaborator

Okay, here's a basic example that deploys via GitHub Actions.

https://github.com/dglsparsons/rust-vercel-demo/

The one endpoint it creates is available here.

Hope this helps!

@PaulRBerg
Copy link
Author

Thanks very much, @dglsparsons we have made our CI script work with your help.

Some feedback for this repo: a section about GitHub Actions/ CI would go a long way. I'm sure others will be in our shoes in the future.

@PaulRBerg
Copy link
Author

Update: installing Rust with the target x86_64-unknown-linux-musl was not enough. We've also had to install musl-tools using this action:

- name: "Install musl-tools to provide musl-gcc"
  uses: awalsh128/cache-apt-pkgs-action@v1
  with:
    packages: "musl-tools"
    version: "1.0"

I suspect that this is because one of our dependencies required musl-tools.

Again, I think that documenting these processes in the README of this repository would be tremendously valuable for Vercel users who wish to deploy Rust-based APIs.

I could take a stab at a PR, but I'm pretty sure that I would butcher the explanation.

References:

And:

See full CI error details

error: failed to run custom build command for ring v0.17.5

Caused by:
process didn't exit successfully: /home/runner/work/v2-services/v2-services/target/release/build/ring-327408199bad9369/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_5_
OPT_LEVEL = Some("3")
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-musl
CC_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_musl
CC_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
RUSTC_LINKER = None
cargo:rerun-if-env-changed=CROSS_COMPILE
CROSS_COMPILE = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-musl
CFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_musl
CFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
running: "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "include" "-I" "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/ring-288238f42a152ef2/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-DNDEBUG" "-o" "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/ring-288238f42a152ef2/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"

--- stderr

error occurred: Failed to find tool. Is musl-gcc installed?

error: failed to run custom build command for openssl-sys v0.9.95

Caused by:
process didn't exit successfully: /home/runner/work/v2-services/v2-services/target/release/build/openssl-sys-f28fdd44215f9e0c/build-script-main (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_NO_VENDOR
X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-musl
CC_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_musl
CC_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
RUSTC_LINKER = None
cargo:rerun-if-env-changed=CROSS_COMPILE
CROSS_COMPILE = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-musl
CFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_musl
CFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=AR_x86_64-unknown-linux-musl
AR_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=AR_x86_64_unknown_linux_musl
AR_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_AR
TARGET_AR = None
cargo:rerun-if-env-changed=AR
AR = None
cargo:rerun-if-env-changed=ARFLAGS_x86_64-unknown-linux-musl
ARFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=ARFLAGS_x86_64_unknown_linux_musl
ARFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_ARFLAGS
TARGET_ARFLAGS = None
cargo:rerun-if-env-changed=ARFLAGS
ARFLAGS = None
cargo:rerun-if-env-changed=RANLIB_x86_64-unknown-linux-musl
RANLIB_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=RANLIB_x86_64_unknown_linux_musl
RANLIB_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_RANLIB
TARGET_RANLIB = None
cargo:rerun-if-env-changed=RANLIB
RANLIB = None
cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64-unknown-linux-musl
RANLIBFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64_unknown_linux_musl
RANLIBFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_RANLIBFLAGS
TARGET_RANLIBFLAGS = None
cargo:rerun-if-env-changed=RANLIBFLAGS
RANLIBFLAGS = None
running cd "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src" && env -u CROSS_COMPILE AR="ar" CC="musl-gcc" RANLIB="ranlib" "perl" "./Configure" "--prefix=/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-async" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-DOPENSSL_NO_SECURE_MEMORY"
Configuring OpenSSL version 3.1.2 for target linux-x86_64
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
Created include/openssl/configuration.h



*** OpenSSL has been successfully configured ***


*** If you encounter a problem while building, please open an ***
*** issue on GitHub https://github.com/openssl/openssl/issues ***
*** and include the output from the following command: ***


*** perl configdata.pm --dump ***


*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL.md file first) ***



running cd "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src" && "make" "depend"
running cd "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=9,14 --jobserver-auth=9,14" "make" "build_libs"
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/asn1.h.in > include/openssl/asn1.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/asn1t.h.in > include/openssl/asn1t.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/bio.h.in > include/openssl/bio.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/cmp.h.in > include/openssl/cmp.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/cms.h.in > include/openssl/cms.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/conf.h.in > include/openssl/conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/crmf.h.in > include/openssl/crmf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/crypto.h.in > include/openssl/crypto.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ct.h.in > include/openssl/ct.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/err.h.in > include/openssl/err.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ess.h.in > include/openssl/ess.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/fipskey.h.in > include/openssl/fipskey.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/lhash.h.in > include/openssl/lhash.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ocsp.h.in > include/openssl/ocsp.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/opensslv.h.in > include/openssl/opensslv.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/pkcs12.h.in > include/openssl/pkcs12.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/pkcs7.h.in > include/openssl/pkcs7.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/safestack.h.in > include/openssl/safestack.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/srp.h.in > include/openssl/srp.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ssl.h.in > include/openssl/ssl.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ui.h.in > include/openssl/ui.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/x509.h.in > include/openssl/x509.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/x509_vfy.h.in > include/openssl/x509_vfy.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/x509v3.h.in > include/openssl/x509v3.h
make depend && make _build_libs
make[1]: Entering directory '/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src'
make[1]: Leaving directory '/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src'
make[1]: Entering directory '/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src'
musl-gcc -I. -Iinclude -Iapps/include -fPIC -pthread -m64 -Wall -O3 -O2 -ffunction-sections -fdata-sections -fPIC -m64 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR=""/usr/local/ssl"" -DENGINESDIR=""/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/install/lib/engines-3"" -DMODULESDIR=""/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/install/lib/ossl-modules"" -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -DOPENSSL_NO_SECURE_MEMORY -c -o apps/lib/libapps-lib-app_libctx.o apps/lib/app_libctx.c
musl-gcc -I. -Iinclude -Iapps/include -fPIC -pthread -m64 -Wall -O3 -O2 -ffunction-sections -fdata-sections -fPIC -m64 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR=""/usr/local/ssl"" -DENGINESDIR=""/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/install/lib/engines-3"" -DMODULESDIR=""/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/install/lib/ossl-modules"" -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -DOPENSSL_NO_SECURE_MEMORY -c -o apps/lib/libapps-lib-app_params.o apps/lib/app_params.c
make[1]: Leaving directory '/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src'

--- stderr
/bin/sh: 1: musl-gcc: not found
make[1]: *** [Makefile:2395: apps/lib/libapps-lib-app_libctx.o] Error 127
make[1]: *** Waiting for unfinished jobs....
/bin/sh: 1: musl-gcc: not found
make[1]: *** [Makefile:2397: apps/lib/libapps-lib-app_params.o] Error 127
make: *** [Makefile:1413: build_libs] Error 2
thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-300.1.3+3.1.2/src/lib.rs:573:9:

Error building OpenSSL:
Command: cd "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=9,14 --jobserver-auth=9,14" "make" "build_libs"
Exit status: exit status: 2

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Error: Command failed with exit code 101: cargo build --bin create --quiet --release
Error: Process completed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants