denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[Bug]: static site generator endpoint doesn't work #713

Open jakeg opened 2 months ago

jakeg commented 2 months ago

Problem description

When setting up a new project it says:

Entrypoint
The “entrypoint” to your application is the file that Deno Deploy will execute to start your server. Specify the path to that file in the “Entrypoint” field.

If you are using a static site generator, you might use this file as your entrypoint:

https://deno.land/std@0.188.0/http/file_server.ts

This is a generic static file server that will serve static assets from the root directory.

... but it won't let you set https://deno.land/std@0.188.0/http/file_server.ts as the entrypoint ('no branches found'), only local files.

Steps to reproduce

Expected behavior

let's you, or the docs are changed

Environment

n/a

Possible solution

No response

Additional context

No response

jakeg commented 1 month ago

it seems to allow the entrypoint if I simply set the build step to a no-op, eg echo 1

jakeg commented 1 month ago

... however, this creates a .github/workflows/deploy.yml which is totally unnecessary if all I want to do is host a static website which doesn't include a build step.

Is there no way to just use deno deploy with a website which doesn't use a build step, thus skipping GitHub actions? ie just setting the entrypoint to https://deno.land/std@0.217.0/http/file_server.ts?

mxdvl commented 1 month ago

I think the deployctl action needs to run outside of the Deploy environment, so it can work properly and decide which files should be included, which should be ignored, and which ones have changed.

When using the entrypoint method without a build step, only the files that are directly referenced by the entrypoint will be uploaded, after a module graph has been created, similar to the output you’d get from deno info entrypoint.ts.

jakeg commented 1 month ago

Thanks @mxdvl

But if I have a website deployed with Deno Deploy (which I do) , that uses a custom server.js file as an entrypoint, all files in the repo are uploaded to Deno Deploy. So you're saying when you use an external entrypoint file instead, it won't add the contents of the repo to Deno Deploy?

mxdvl commented 1 month ago

Okay, I wasn’t aware of this 🤔 – in my experience only JS files referenced by the server were uploaded which is why I use Github Action for all my static sites on Deploy™. I guess clarifying the docs would help!

jakeg commented 1 month ago

Just to be really clear: I'm talking about a simple website which is just eg HTML files stored in a GitHub repo, where there no building static pages via build scripts and no dependencies to install at all.

jakeg commented 1 month ago

It's annoying to have to add one, but my solution for now is to add a server.js and make that the entrypoint:

import { serveDir } from  'jsr:@std/http/file-server'
Deno.serve({}, serveDir)

... by doing this rather than my workaround above, deploy time comes down to 1-10s instead of ~30s, as it skips the totally unnecessary GitHub actions.

To confirm @mxdvl - all files in my git repo are added without GitHub actions (but not any I would build if I had a build step, which I don't).

Is there really no way to set an external entrypoint without also using GitHub actions?