How to deply a custom Deno main.ts project ?

I created a custom deno main.ts file :

const server = Deno.listen({ port: 8080 });
console.log(`HTTP webserver running. Access it at:  http://localhost:8080/`);
// some code
for await (const conn of server)
{
    serveHttp(conn);
}

It’s running on my localhost :

deno run --allow-net main.ts
A new release of Deno is available: 1.29.2 → 1.31.1 Run `deno upgrade` to install it.
HTTP webserver running. Access it at:  http://localhost:8080/

But I don’t know what to do to deploy :

$fly launch
Creating app in /workspace/deno/project-name
Scanning source code
Could not find a Dockerfile, nor detect a runtime or framework from source code. Continuing with a blank app.
? Choose an app name (leave blank to generate one): 

Now what next to get fly detect it as a Deno app /

That deno app seems incomplete. This one works better for me:

const server = Deno.listen({ port: 8080 });
console.log(`HTTP webserver running. Access it at:  http://localhost:8080/`);
// some code
for await (const conn of server)
{
    for await (const e of Deno.serveHttp(conn)) {
        e.respondWith(new Response("Hello World"));
    }
}

Now to launch it, you will need a Dockerfile. Try this one:

FROM denoland/deno
RUN mkdir deno
WORKDIR deno
COPY . .
EXPOSE 8080
ENTRYPOINT ["deno", "run", "--allow-net", "main.ts"]

From How To to Questions / Help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.