Skip to content

Commit

Permalink
Add base for faas/deploy in linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Aug 21, 2024
1 parent 86344f9 commit d9dde87
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 16 deletions.
56 changes: 42 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ FROM debian_root AS test_debian_root_wget_from_path

RUN wget https://github.com/metacall/distributable-linux/releases/download/v0.7.0/metacall-tarball-linux-amd64.tar.gz \
&& wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | bash -s -- --from-path /metacall-tarball-linux-amd64.tar.gz \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test install Debian with root and curl
FROM debian_root AS test_debian_root_curl

RUN curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | bash \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test certificates in Debian with root (comparing against <!doctype html> in buffer format)
FROM test_debian_root_curl AS test_debian_root_certificates
Expand All @@ -87,13 +91,17 @@ RUN export WEB_RESULT="`printf 'load py /test/script.py\ninspect\ncall fetch_htt
FROM debian_root AS test_debian_root_wget

RUN wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | bash \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test install Debian without root and curl
FROM debian_user AS test_debian_user_curl

RUN curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | bash \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test certificates in Debian with user (comparing against <!doctype html> in buffer format)
FROM test_debian_user_curl AS test_debian_user_certificates
Expand All @@ -106,13 +114,17 @@ RUN export WEB_RESULT="`printf 'load py /test/script.py\ninspect\ncall fetch_htt
FROM debian_user AS test_debian_user_wget

RUN wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | bash \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test reinstall Debian without root and wget
FROM test_debian_user_wget AS test_debian_user_wget_reinstall

RUN wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | bash -s -- --update \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test pip installation
FROM test_debian_user_wget AS test_debian_user_pip
Expand Down Expand Up @@ -159,19 +171,25 @@ RUN curl -sL https://raw.githubusercontent.com/metacall/install/master/install.s
FROM fedora_root AS test_fedora_root_wget

RUN wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | bash \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test install Fedora without root and curl
FROM fedora_user AS test_fedora_user_curl

RUN curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | bash \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test install Fedora without root and wget
FROM fedora_user AS test_fedora_user_wget

RUN wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | bash \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Alpine Base (root)
FROM alpine:latest AS alpine_root
Expand Down Expand Up @@ -200,25 +218,33 @@ USER user
FROM alpine_root AS test_alpine_root_curl

RUN curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | sh \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test install Alpine with root and wget
FROM alpine_root AS test_alpine_root_wget

RUN wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | sh \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test install Alpine without root and curl
FROM alpine_user AS test_alpine_user_curl

RUN curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | sh \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test install Alpine without root and wget
FROM alpine_user AS test_alpine_user_wget

RUN wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | sh \
&& metacall /test/script.js | grep '123456'
&& metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

# Test update Alpine
FROM test_alpine_user_wget AS test_alpine_user_wget_update
Expand Down Expand Up @@ -261,6 +287,8 @@ FROM test_busybox_base AS busybox_without_certificates_remote

RUN wget --no-check-certificate -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | sh \
-s -- --no-check-certificate \
&& sh /usr/local/bin/metacall /test/script.js | grep '123456'
&& sh /usr/local/bin/metacall /test/script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'

FROM busybox_without_${METACALL_INSTALL_CERTS} AS test_busybox_without_certificates
24 changes: 24 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ binary_install() {

# Install CLI
cli

# Install additional dependencies
additional_packages_install
}

docker_install() {
Expand Down Expand Up @@ -543,6 +546,27 @@ uninstall() {
fi
}

additional_packages_install() {
local install_dir="/gnu/deps"
local bin_dir="/gnu/bin"

print "Installing additional dependencies."

# Install Deploy
metacall npm install --global --prefix="${install_dir}/deploy" @metacall/deploy
echo "#!${CMD_SHEBANG}" &> ${bin_dir}/deploy
echo "metacall node ${install_dir}/deploy/lib/node_modules/@metacall/deploy/dist/index.js \$@" >> ${bin_dir}/deploy
chmod 755 "${bin_dir}/deploy"

# Install FaaS
metacall npm install --global --prefix="${install_dir}/faas" @metacall/faas
echo "#!${CMD_SHEBANG}" &> ${bin_dir}/faas
echo "metacall node ${install_dir}/faas/lib/node_modules/@metacall/faas/dist/index.js \$@" >> ${bin_dir}/faas
chmod 755 "${bin_dir}/faas"

success "Additional dependencies installed."
}

main() {
# Check if the tarball is correct
if [ $OPT_FROM_PATH -eq 1 ]; then
Expand Down
8 changes: 6 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ docker run --rm \
sh -c "wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | sh -s -- --docker-install \
&& mkdir -p ${DOCKER_HOST_PATH} \
&& cd ${DOCKER_HOST_PATH} \
&& metacall script.js | grep '123456'"
&& metacall script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'"

result=$?
if [[ $result -ne 0 ]]; then
Expand All @@ -106,7 +108,9 @@ docker run --rm \
&& sh ./install.sh \
&& mkdir -p ${DOCKER_HOST_PATH} \
&& cd ${DOCKER_HOST_PATH} \
&& metacall script.js | grep '123456'"
&& metacall script.js | grep '123456' \
&& metacall deploy --version | grep -e '^v.*\..*\..*' \
&& metacall faas --version | grep -e '^v.*\..*\..*'"

result=$?
if [[ $result -ne 0 ]]; then
Expand Down

0 comments on commit d9dde87

Please sign in to comment.