deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

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

Open jakeg opened this issue 1 year ago • 7 comments

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/[email protected]/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/[email protected]/http/file_server.ts as the entrypoint ('no branches found'), only local files.

Steps to reproduce

  • try to create 'new project'
  • enter https://deno.land/[email protected]/http/file_server.ts as the entrypoint
  • doesn't let you

Expected behavior

let's you, or the docs are changed

Environment

n/a

Possible solution

No response

Additional context

No response

jakeg avatar Sep 13 '24 06:09 jakeg

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

jakeg avatar Sep 25 '24 05:09 jakeg

... 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/[email protected]/http/file_server.ts?

jakeg avatar Sep 25 '24 07:09 jakeg

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.

mxdvl avatar Sep 25 '24 08:09 mxdvl

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?

jakeg avatar Sep 25 '24 08:09 jakeg

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!

mxdvl avatar Sep 25 '24 08:09 mxdvl

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 avatar Sep 25 '24 17:09 jakeg

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?

jakeg avatar Sep 26 '24 04:09 jakeg