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

0.3.0-beta.22 perseus deploy Found argument 'standalone' which wasn't expected, or isn't valid in this context #92

Closed
phaleth opened this issue Dec 13, 2021 · 3 comments

Comments

@phaleth
Copy link
Contributor

phaleth commented Dec 13, 2021

Describe the bug
This time the docker image build error is not VPS related. The error is reproducable locally. It's most likely related to the removal of PERSEUS_STANDALONE env var in the d178f5a commit. Removal of optimizations doesn't fix the issue.

To Reproduce
Dockerfile

# get the base image
FROM rust:1.57-slim AS build

# install build dependencies
RUN apt update \
  && apt install -y --no-install-recommends lsb-release apt-transport-https \
  build-essential curl

# vars
ENV PERSEUS_VERSION=0.3.0-beta.22 \
    WEE_ALLOC_VERSION=0.4

# prepare root project dir
WORKDIR /app

# download the target for wasm
RUN rustup target add wasm32-unknown-unknown

# install wasm-pack
RUN cargo install wasm-pack

# retrieve the src dir
RUN curl https://codeload.github.com/arctic-hen7/perseus/tar.gz/v${PERSEUS_VERSION} | tar -xz --strip=2 perseus-${PERSEUS_VERSION}/examples/tiny

# go to src dir
WORKDIR /app/tiny

# install perseus-cli
RUN cargo install perseus-cli --version $PERSEUS_VERSION

# clean app
RUN perseus clean

# specify deps in app config
RUN sed -i s"/perseus = .*/perseus = \"${PERSEUS_VERSION}\"/" ./Cargo.toml \
  && sed -i "/\[dependencies\]/a wee_alloc = \"${WEE_ALLOC_VERSION}\"" ./Cargo.toml \
  && cat ./Cargo.toml

# modify and prepend lib.rs
RUN echo '#[global_allocator] \n\
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; \n\
' | cat - ./src/lib.rs > ./src/lib.rs.tmp \
  && mv ./src/lib.rs.tmp ./src/lib.rs \
  && cat ./src/lib.rs

# prep and eject app
RUN perseus prep && perseus eject

# adjust and append perseus config
RUN sed -i s"/perseus = .*/perseus = \"${PERSEUS_VERSION}\"/" .perseus/Cargo.toml \
  && echo ' \n\n\
[profile.release] \n\
codegen-units = 1 \n\
opt-level = "s" ' >> .perseus/Cargo.toml \
  && cat .perseus/Cargo.toml

# single-threaded perseus CLI mode
#ENV PERSEUS_CLI_SEQUENTIAL=true

# deploy app
RUN perseus deploy

# prepare deployment image
FROM bitnami/minideb:buster

WORKDIR /app

COPY --from=build /app/tiny/pkg /app/

ENV HOST=0.0.0.0

CMD ["./server"]

Last steps of docker build output

...
Step 9/20 : RUN cargo install perseus-cli --version $PERSEUS_VERSION
 ---> Running in 524858d24f44
 Downloading crates ...
  Downloaded perseus-cli v0.3.0-beta.22
    Updating crates.io index
  Installing perseus-cli v0.3.0-beta.22
 Downloading crates ...
  Downloaded include_dir_impl v0.6.2
  Downloaded os_str_bytes v4.2.0
  Downloaded include_dir v0.6.2
  Downloaded clap_derive v3.0.0-beta.5
  Downloaded clap v3.0.0-beta.5
  Downloaded indicatif v0.17.0-beta.1
  Downloaded fmterr v0.1.1
  Downloaded anyhow v1.0.51
  Downloaded textwrap v0.14.2
  Downloaded cargo_toml v0.9.2
  Downloaded strsim v0.10.0
  Downloaded console v0.14.1
  Downloaded proc-macro-hack v0.5.19
  Downloaded glob v0.3.0
  Downloaded number_prefix v0.4.0
  Downloaded fs_extra v1.2.0
   Compiling proc-macro2 v1.0.33
   Compiling unicode-xid v0.2.2
   Compiling version_check v0.9.3
   Compiling syn v1.0.82
   Compiling libc v0.2.111
   Compiling serde v1.0.131
   Compiling memchr v2.4.1
   Compiling anyhow v1.0.51
   Compiling autocfg v1.0.1
   Compiling proc-macro-hack v0.5.19
   Compiling unicode-segmentation v1.8.0
   Compiling serde_derive v1.0.131
   Compiling regex-syntax v0.6.25
   Compiling lazy_static v1.4.0
   Compiling unicode-width v0.1.9
   Compiling once_cell v1.8.0
   Compiling serde_json v1.0.72
   Compiling hashbrown v0.11.2
   Compiling itoa v0.4.8
   Compiling bitflags v1.3.2
   Compiling termcolor v1.1.2
   Compiling glob v0.3.0
   Compiling strsim v0.10.0
   Compiling ryu v1.0.9
   Compiling number_prefix v0.4.0
   Compiling fs_extra v1.2.0
   Compiling fmterr v0.1.1
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling unicase v2.6.0
   Compiling textwrap v0.14.2
   Compiling indexmap v1.7.0
   Compiling heck v0.3.3
   Compiling regex v1.5.4
   Compiling os_str_bytes v4.2.0
   Compiling quote v1.0.10
   Compiling terminal_size v0.1.17
   Compiling atty v0.2.14
   Compiling console v0.15.0
   Compiling console v0.14.1
   Compiling indicatif v0.17.0-beta.1
   Compiling toml v0.5.8
   Compiling thiserror-impl v1.0.30
   Compiling include_dir_impl v0.6.2
   Compiling clap_derive v3.0.0-beta.5
   Compiling include_dir v0.6.2
   Compiling thiserror v1.0.30
   Compiling clap v3.0.0-beta.5
   Compiling cargo_toml v0.9.2
   Compiling perseus-cli v0.3.0-beta.22
    Finished release [optimized] target(s) in 53.40s
  Installing /usr/local/cargo/bin/perseus
   Installed package `perseus-cli v0.3.0-beta.22` (executable `perseus`)
Removing intermediate container 524858d24f44
 ---> 44cd5371ad66
Step 10/20 : RUN perseus clean
 ---> Running in 746e8612be6d
Removing intermediate container 746e8612be6d
 ---> d726f1ecced5
Step 11/20 : RUN sed -i s"/perseus = .*/perseus = \"${PERSEUS_VERSION}\"/" ./Cargo.toml   && sed -i "/\[dependencies\]/a wee_alloc = \"${WEE_ALLOC_VERSION}\"" ./Cargo.toml   && cat ./Cargo.toml
 ---> Running in a0393a01f3b2
[package]
name = "perseus-example-tiny"
version = "0.3.0-beta.22"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
wee_alloc = "0.4"
perseus = "0.3.0-beta.22"
sycamore = "0.7"
Removing intermediate container a0393a01f3b2
 ---> 7119c7d72c91
Step 12/20 : RUN echo '#[global_allocator] \nstatic ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; \n' | cat - ./src/lib.rs > ./src/lib.rs.tmp   && mv ./src/lib.rs.tmp ./src/lib.rs   && cat ./src/lib.rs
 ---> Running in 8c126cc67777
#[global_allocator] 
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 

use perseus::{define_app, ErrorPages, Template};
use sycamore::view;
define_app! {
    templates: [
        Template::<G>::new("index").template(|_| {
            view! {
                p { "Hello World!" }
            }
        })
    ],
    error_pages: ErrorPages::new(|url, status, err, _| {
        view! {
            p { (format!("An error with HTTP code {} occurred at '{}': '{}'.", status, url, err)) }
        }
    })
}
Removing intermediate container 8c126cc67777
 ---> 90d600cfa712
Step 13/20 : RUN perseus prep && perseus eject
 ---> Running in 97a615055653
Removing intermediate container 97a615055653
 ---> 437d83dd9e95
Step 14/20 : RUN sed -i s"/perseus = .*/perseus = \"${PERSEUS_VERSION}\"/" .perseus/Cargo.toml   && echo ' \n\n[profile.release] \ncodegen-units = 1 \nopt-level = "s" ' >> .perseus/Cargo.toml   && cat .perseus/Cargo.toml
 ---> Running in f99a56968b25
# This crate defines the user's app in terms that Wasm can understand, making development significantly simpler.
# IMPORTANT: spacing matters in this file for runtime replacements, do NOT change it!

[package]
name = "perseus-engine"
version = "0.3.0-beta.22"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# We alias here because the package name will change based on whatever's in the user's manifest
app = { package = "perseus-example-tiny", path = "../" }

perseus = "0.3.0-beta.22"
sycamore = { version = "0.7", features = ["ssr"] }
sycamore-router = "0.7"
web-sys = { version = "0.3", features = ["Event", "Headers", "Request", "RequestInit", "RequestMode", "Response", "ReadableStream", "Window"] }
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
console_error_panic_hook = "0.1.6"

# This section is needed for Wasm Pack (which we use instead of Trunk for flexibility)
[lib]
crate-type = ["cdylib", "rlib"]

[features]
# This changes a few things to support running as a standalone server binary (this is set by `perseus deploy`, do NOT invoke this manually!)
standalone = []

[workspace] 

[profile.release] 
codegen-units = 1 
opt-level = "s" 
Removing intermediate container f99a56968b25
 ---> 91f0d5e40950
Step 15/20 : RUN perseus deploy
 ---> Running in a7106ce3b3dd
error: Found argument 'standalone' which wasn't expected, or isn't valid in this context

USAGE:
    cargo build --features <FEATURES>... --message-format <FMT>... --release

For more information try --help
The command '/bin/sh -c perseus deploy' returned a non-zero code: 1

Expected behavior
Build the docker image as expected.

Environment:

  • Perseus Version: 0.3.0-beta.22
  • Sycamore Version: 0.7
  • OS: debian 10
  • Browser: not relevant
  • Browser Version: not relevant

Additional context
The Dockerfile is standalone. Note that here the standalone keyword shouldn't be confused with the standalone term used to describe the issue.

@arctic-hen7
Copy link
Member

I'm pretty sure this is actually caused by the addition of the ability to switch to a different server integration, which is impacting the way standalone builds work. This should be a very easy fix, thanks for letting me know (this is what happens when apt breaks on CI...).

@arctic-hen7
Copy link
Member

This is fixed in beta 23, it was caused by my forgetting to put in a --features where one was needed (because cargo has some very odd flag requirements).

@phaleth
Copy link
Contributor Author

phaleth commented Dec 14, 2021

Thank you, @arctic-hen7.

perseus deploy now works locally. With esbuild in place the site runs on Pale Moon, which is not so fully featured but still regularly updated web browser.

Dockerfile

# get the base image
FROM rust:1.57-slim AS build

# install build dependencies
RUN apt update \
  && apt install -y --no-install-recommends lsb-release apt-transport-https \
  build-essential curl

# vars
ENV PERSEUS_VERSION=0.3.0-beta.23 \
    PERSEUS_SIZE_OPT_VERSION=0.1.5 \
    ESBUILD_VERSION=0.14.4

# prepare root project dir
WORKDIR /app

# download the target for wasm
RUN rustup target add wasm32-unknown-unknown

# install wasm-pack
RUN cargo install wasm-pack

# retrieve the src dir
RUN curl https://codeload.github.com/arctic-hen7/perseus-size-opt/tar.gz/main | tar -xz --strip=2 perseus-size-opt-main/examples/simple

# go to src dir
WORKDIR /app/simple

# install perseus-cli
RUN cargo install perseus-cli --version $PERSEUS_VERSION

# clean and prep app
RUN perseus clean && perseus prep

# specify deps in app config
RUN sed -i s"/perseus = .*/perseus = \"${PERSEUS_VERSION}\"/" ./Cargo.toml \
  && sed -i s"/perseus-size-opt = .*/perseus-size-opt = \"${PERSEUS_SIZE_OPT_VERSION}\"/" ./Cargo.toml \
  && cat ./Cargo.toml

# modify lib.rs
RUN sed -i s'/SizeOpts::default()/SizeOpts { wee_alloc: true, lto: false, opt_level: "s".to_string(), codegen_units: 1, enable_fluent_bundle_patch: false, }/' ./src/lib.rs \
  && cat ./src/lib.rs

# run plugin(s) to adjust app
RUN perseus tinker \
  && cat .perseus/Cargo.toml \
  && cat ./src/lib.rs

# single-threaded perseus CLI mode
#ENV PERSEUS_CLI_SEQUENTIAL=true

# deploy app
RUN perseus deploy

# go back to app dir
WORKDIR /app

# download and unpack esbuild
RUN curl -O https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-${ESBUILD_VERSION}.tgz \
  && tar xf esbuild-linux-64-${ESBUILD_VERSION}.tgz \
  && ./package/bin/esbuild --version

# run esbuild against bundle.js
RUN ./package/bin/esbuild ./simple/pkg/dist/pkg/perseus_engine.js --minify --target=es6 --outfile=./simple/pkg/dist/pkg/perseus_engine.js --allow-overwrite \
  && ls -lha ./simple/pkg/dist/pkg

# prepare deployment image
FROM bitnami/minideb:buster

WORKDIR /app

COPY --from=build /app/simple/pkg /app/

ENV HOST=0.0.0.0

CMD ["./server"]

image

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