letsdiscodev / example-static-site

MIT License
0 stars 2 forks source link

support for processing / Makefile / etc #1

Open schollz opened 8 months ago

schollz commented 8 months ago

I often use Hugo or Jekyll for static sites. is there a way to include a hook to tell disco to build the static site? or would the solution be to include a Dockerfile that builds the site and binds it to a volume (might be better in case of Jekyll which had dependency nightmares sometimes)?

antoineleclair commented 8 months ago

Hey @schollz!

Thanks for the question and feedback.

It's definitely in the plans to have something specifically for that.

The plan would be to still rely on Docker and a Dockerfile to have all the dependencies, and then define a command that would run when deploying.

Just drafting, a disco.json file could look like that:

{
    "version": "1.0",
    "services": {
        "web": {
            "type": "static",
            "publicPath": "/dist"
            "buildCommand": "jekyll build",
            "volumes": [{
                "sourcePath": "/src",
                "destinationPath": "/src"
            },{
                "sourcePath": "/dist",
                "destinationPath": "/dist"
            }]
        }
    }
}

For now, two ways to work around the fact that it's not directly possible yet would be to build and commit to either the same repo, or a separate "deployment repo", or instead of trying to let Disco serve the static files, you could run the server in your app. For the second option, have a look at this other example (Django) that has a "pre deploy" command: https://github.com/letsdiscodev/example-django-site/blob/4028c926b9a85efd2800b9362c6d2c10c67d1ff4/disco.json#L9-L14

I'm leaving this issue open since we'll be working on this soon.

gregsadetsky commented 8 months ago

some comparison notes below


render does it like this for reference:

https://docs.render.com/deploy-hugo

they run a pre-installed hugo which is both convenient but not great since then the hugo version can't be controlled for instance. there's a thread on this topic here:

https://community.render.com/t/how-to-define-hugo-version/390/9

(they go through the manual hugo installation steps in that thread)


fly is heavier since you're defining everything with dockerfiles, and need to handle the caddy installation:

https://fly.io/blog/hugo-s-there-flying-with-hugo-and-caddy/

they end up using this docker image


for github pages, there's this github actions that takes care of installing hugo

gregsadetsky commented 7 months ago

hey @schollz , @antoineleclair worked his usual magic and we now fully support static-sites-with-build-steps!

hugo docs are here: https://docs.letsdisco.dev/tldr-guides/deploying-a-hugo-static-site example hugo repo is here: https://github.com/letsdiscodev/example-hugo-site

all of the good stuff happens in that repo's disco.json -> we pull the floryn90/hugo docker image, and, as its entrypoint is the hugo binary, we pass in the disco.json command the build instructions + directory destination

deployments are ......... scarily fast. I'm very honestly not used to cloud deployments this fast. I recorded this video where I make a small change to the example hugo site and continuously wget+grep the site. it takes 3 seconds from git push to the site being built + made live. 3!!!. 3!!!!!!!!!!! :-)

let us know what you think / if this works!! cheers

p.s. jekyll's coming too! DONE! see below

gregsadetsky commented 7 months ago

... and Jekyll works now too!

docs: https://docs.letsdisco.dev/tldr-guides/deploying-a-jekyll-site example repo: https://github.com/letsdiscodev/example-jekyll-site

let us know!! :-)