Skip to content

Update CMD to serve instead of run; remove deps.ts in favor of deno.json#440

Open
kimdcottrell wants to merge 5 commits intodenoland:mainfrom
kimdcottrell:424_update_serve
Open

Update CMD to serve instead of run; remove deps.ts in favor of deno.json#440
kimdcottrell wants to merge 5 commits intodenoland:mainfrom
kimdcottrell:424_update_serve

Conversation

@kimdcottrell
Copy link

This fixes this issue:

#424

You can fix that issue as well by keeping the CMD as is, but you have to alter the main.ts to be:

Deno.serve(
    { port: 1993, hostname: "0.0.0.0" }, 
    (_req) => new Response("Hello, world")
);

I went with deno serve since you can keep all the hostname and port configs in the Dockerfile and reduce repetition.

deps.ts was removed in favor of demo.json as it, or package.json , seems to be the path forward in Deno 2.

@CLAassistant
Copy link

CLAassistant commented Jan 3, 2025

CLA assistant check
All committers have signed the CLA.

COPY deps.ts .
RUN deno install --entrypoint deps.ts
# Cache the dependencies as a layer (the following two steps are re-run only when deno.json is modified).
# Ideally cache deno.json will download and compile _all_ external files used in main.ts.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not preferable. With deno cache on like 62, we are going to install only dependencies that are actually used. Here all deps are installed, even if they are unused. We should wait for denoland/deno#27229

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. The dependency install and the caching of it should be sorted first.

The main reason I made this PR was to overcome an issue around the CMD and how the webserver was running, which would throw an error thanks to the approach it was using.

The deps.ts -> deno.json blurb got caught up in this since that also appears to be a remnant from Deno 1.

I'll try to keep an eye on your PR, and once it's merged, I'll alter this one to reflect your approach.

@fry69
Copy link

fry69 commented Jul 29, 2025

Since the mentioned denoland/deno#27229 issue has been closed as completed, and I just stumbled over some idiosyncrasies with deno install vs deno cache, also in the end with deno serve while using Docker/Podman:

Is there any news on this?

The examples with deps.ts without further explanation how to use this seems very counterintuitive in the age of deno.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants