H
Hono8mo ago
PaperKrane

Deploy Hono / Bun API

I know, I know this is such a newby question but I come from small express apps and other simple ‘click to deploy’ frameworks. I recently discovered Hono and more recently tried to build the app out on Bun because the built in web sockets are amazing. I am just at a loss how to deploy the small API I built. Any insights / examples of how one might deploy a simple API with Hono/Bun would be amazing. I feel like Docker is my best bet but am still not a master with it. Should add, I would appreciate any docs or articles that might help as well. Just excited to push this thing and test it out on a production server. Thanks to all who take the time to read! Best wishes!
7 Replies
Nico
Nico8mo ago
If you want an easy foolproof way to deploy it you can use a digital ocean app platform. They don’t support bun, but if you bundle it you can use node. Or you can write a dockerfile and it will create a container and run that It does all the server work for you, so you don’t have to worry about setting up a reverse proxy with Nginx or anything. The cheapest plan is $5 a month a believe If you do decide that use that and have never used digital ocean, I can send you a promo for free credit, it helps me out too. Or if you wanna try docker compose I can help you write it out with a reverse proxy as well
PaperKrane
PaperKraneOP8mo ago
@Nico I have a few projects on DigitalOcean and honestly love it. I wish I could take you up on the free credit but as I am an existing customer, I doubt it’d do anything for me. But if it helps you I’d still be willing to try! As for the Docker image, I would appreciate any help you’re willing to offer. Trying to pour over the Docker docs right now but as it is when learning anything, it will take a bit of time.
Nico
Nico8mo ago
No worries at all! Did you want to do docker on your own server? Or try a docker image on the app platform I’ll give you both options here in a bit actually once I get to my computer
PaperKrane
PaperKraneOP8mo ago
You are awesome! I was leaning towards App Platform because of the ‘Hassle Free’ it offers. Are the Dockers files that different? I’m excited to study them and try to get an understanding of the whole thing. Thanks again @Nico you are truly a lifesaver!
Nico
Nico8mo ago
Docker file is the first step to doing it all on docker. Sorry it’s gonna be a little bit until I can get it to you You can also do a bun build and run on node on app platform. But tonight I’ll get you that dockerfile This should be all you need
# Dockerfile.yaml
FROM oven/bun

WORKDIR /app

COPY package.json .
COPY bun.lockb .

RUN bun install --production

COPY src src

CMD ["bun", "run", "src/index.ts"]

EXPOSE 3000
# Dockerfile.yaml
FROM oven/bun

WORKDIR /app

COPY package.json .
COPY bun.lockb .

RUN bun install --production

COPY src src

CMD ["bun", "run", "src/index.ts"]

EXPOSE 3000
If you have any questions let me know. You can also create a bun build instead that will run the code all complied into a single file. The important thing to note is everytime you use COPY the data is cached. That's why we don't copy everything all at once. So it only the code changes it won't update the packages everytime
PaperKrane
PaperKraneOP8mo ago
This is amazing thank you! Everything I am reading / tutorials I am finding for other Docker files look so much more complex lol
Nico
Nico8mo ago
No problem let me know if you have any issues
Want results from more Discord servers?
Add your server