https://linen.dev logo
Error provisioning static folders
a

astonishing-laptop-19143

05/25/2023, 6:30 PM
Hello! I'm running into some issues when it comes to deploying. I recently added a folder called "static" to my root, containing a SSL cert. Whenever I try to deploy using
shuttle_static_folder::StaticFolder
I receive some errors. Here is my main function along with the error I'm receiving. It works when I run it using cargo shuttle run but doesn't seem to be able to deploy.
#[shuttle_runtime::main]
async fn start(
    #[shuttle_secrets::Secrets] secret_store: SecretStore,
    #[shuttle_static_folder::StaticFolder(folder = "static")] _static_folder: PathBuf
) -> Result<CustomService, shuttle_service::Error> {
    let discord_bot = bot::build_bot(secret_store).await?;
    let built_rocket = rocket::build();
    Ok(CustomService {
        discord_bot,
        built_rocket,
    })
}

https://cdn.discordapp.com/attachments/1111360713752059905/1111360713882079273/image.png

https://cdn.discordapp.com/attachments/1111360713752059905/1111360714217635970/image.png

a

agreeable-painting-48846

05/25/2023, 8:50 PM
heya, what version of cargo-shuttle/shuttle deps are you running?
also would you mind trying to put an empty
index.html
in your static folder? just want to see if anything changes
a

astonishing-laptop-19143

05/25/2023, 9:54 PM
Hey Josh! Here are my shuttle dependencies. I added an index.html and re deployed. Here are the log's I'm now receiving.

https://cdn.discordapp.com/attachments/1111360713752059905/1111411938384167013/image.png

https://cdn.discordapp.com/attachments/1111360713752059905/1111411938698735706/image.png

I believe shuttle is failing to find my file for some reason. Is there some configuration I should be doing?
e

enough-oil-62271

05/25/2023, 9:56 PM
Is the file you're trying to put in in your gitignore?
a

astonishing-laptop-19143

05/25/2023, 9:59 PM
I have
!static/
in my gitignore. Should I be doing
static/SSLCert.pem
?
a

agreeable-painting-48846

05/25/2023, 10:00 PM
try making a .ignore file then writing
!static/
in it
a

astonishing-laptop-19143

05/25/2023, 10:13 PM
Similar errors:

https://cdn.discordapp.com/attachments/1111360713752059905/1111416808784793641/image.png

https://cdn.discordapp.com/attachments/1111360713752059905/1111416809078403233/image.png

a

agreeable-painting-48846

05/25/2023, 10:14 PM
Does the deploy work without the ssl cert?
Just curious since this is the first time I've seen this kind of thing before
a

astonishing-laptop-19143

05/25/2023, 10:20 PM
Yep!

https://cdn.discordapp.com/attachments/1111360713752059905/1111418578403602542/image.png

a

agreeable-painting-48846

05/25/2023, 10:21 PM
Oh I see, it looks like the problem might specifically be with the ssl cert then. Ill bring this up with engineering
a

astonishing-laptop-19143

05/25/2023, 10:21 PM
Hmm alright. Here is the code bit I wrote. It could very well be user error too. I am a newbie when it comes to Rust.
async fn retrieve_tls_connector() -> Result<MakeTlsConnector, openssl::error::ErrorStack> {
    info!("retrieve tls connector");
    let mut builder: openssl::ssl::SslConnectorBuilder = match SslConnector::builder(SslMethod::tls()) {
        Ok(builder) => builder,
        Err(error) => panic!("Error building SSL Connector: {}", error),
    };
    info!("set ssl certificate");
    match builder.set_ca_file("static/SSLCERT.pem") {
        Ok(_) => {
            Ok(MakeTlsConnector::new(builder.build()))
        },
        Err(error) => panic!("Error setting CA file: {}", error),
    }
}
But it works when I do cargo shuttle run. Only an issue on deployment.
a

agreeable-painting-48846

05/25/2023, 10:25 PM
Ah I see is this with the openssl crate?
or similar
Oh I see, I think I know what's happened
Try using the static folder variable from the macro, then appending
/SSLCERT.pem
to it then sending it back to
.set_ca_file
(you might need to convert it back to a &str or whatever, not entirely sure but yeah)
The static folder in shuttle deployment is stored in a different place than at next to the root of the project, so if you try to use a hard coded path it'll just break
a

astonishing-laptop-19143

05/25/2023, 10:40 PM
Ah this makes sense. Okay I'll give this a try later tonight. Thanks a ton!
a

agreeable-painting-48846

05/25/2023, 10:45 PM
Happy to help 😁