How can I make fly Deno run server.js instead main.ts

I am trying to deploy this app

Flyctl deploy looks for main.ts file, while I want to run server.js

It works perfectly locally. Do I have to change something in fly.toml ?

The builtin Deno builder won’t run anything but main.ts. If you remove the [build] section in fly.toml, and add this Dockerfile you should be good to go though:

FROM denoland/deno:1.13.2
USER deno
COPY server.ts deps.* ./
RUN /bin/bash -c "deno cache deps.ts || true"
ADD . .
RUN deno cache server.ts
CMD ["run", "--allow-net", "server.ts"]
1 Like

Do you have a sample app with Dockerfile? I want to see the structure and apply it to my project.

This is my app successfully deployed via flyctl deploy but it’s crashing when I run it.

Do you have any solution?

Ayyy! I solved it.
Thanks for Troubleshooting your Deployment · Fly
Issue was to set hostname to “”

1 Like

Nice, good catch.

Why fly doesn’t have built in support for running file change. It would be convenient to change main.ts to server.js in my fly.toml file.

Also, since I wrapped this with Dockerfile, I can basically run anywhere right? Including Linode, Digital Ocean, AWS?

Yes that’s correct!

The builtin is just a shortcut to a Dockerfile. It’s usually simpler to build a custom Dockerfile than it is to support all the useful options people need.

so I can run this Dockerfile anywhere? or do I need to change something? Like does AWS have special customization requirements before running Docker instance?
I am not familiar with Docker. Why my app is running without docker-compose.yml
docker-ignore files as in ?

This Dockerfile produces a standard docker image. If you install Docker and run docker build . -t my-deno-app it’ll make something you can push to any Docker registry.

You don’t need to make any changes to run it on AWS, but it’s a pain to push a Docker image to AWS and then deploy it. flyctl deploy does in one step what AWS and other places require like 5 steps for.

docker-compose.yml is for building and running multiple docker containers.

.dockerignore is for optimizing build speed, if you have a big .git directory or node_modules that shouldn’t be sent to Docker to do a build, it will speed things up if you ignore them.

If I have 2 Deno apps, how can I wrap them with 1 Dockerfile?

Also, how eco-friendly is? 100% clean energy?

Your best bet is to build a little server.ts that runs both in one process, and put each app in its own subdirectory. You can install a process supervisor to run multiple things in Docker but it’s pretty complex.

We’re pretty good on clean energy. Most of our regions are 100% clean energy, some in more far flung places are not yet. We use Equinix for most datacenters, they have a good progress tracker here: