Remix redefines full-stack development with its innovative server and browser runtime. By leveraging server-side rendering, lightning-fast page loads, and seamless transitions, Remix gives you powerful performance out of the box.
In this post, I'll walk you through how to easily dockerize your Remix app using Bun and get it ready for deployment in no time.
Dockerizing your Remix app starts by defining a Dockerfile. Here's how you can spin up your Remix app in a docker container.
# Use Bun's lightweight image as the baseFROM oven/bun as baseWORKDIR /appENV NODE_ENV="production"
# Build stageFROM base as buildRUN apt-get update -qq && \ apt-get install -y build-essential pkg-config python-is-python3
# Install dependenciesCOPY --link package.json ./RUN bun install --ci
# Build the Remix appRUN bun run build
# Final stageCOPY --link . .FROM baseCOPY --from=build /app /app
# Expose the port and start the appEXPOSE 3000CMD ["bun", "run", "start"]
Pro tip: Bun’s performance is unmatched in this context, making it a great choice to boost build times and speed up your app.
Make sure your image stays lean by ignoring unnecessary files during the build process with a .dockerignore file:
node_modulesnpm-debug.log
With your Dockerfile and .dockerignore in place, you’re now ready to build and run the container:
# Build the Docker imagedocker build -t nischal/bun-app .
# Run the app on port 3000docker run -p 3000:3000 nischal/bun-app
Once your app is running smoothly, push it to Docker Hub:
docker logindocker push nischal/bun-app
With these steps, you've dockerized your Remix app in style, combining the blazing speed of Bun with the flexibility of Docker. Ready to take it further? This setup is perfect for deployment on any cloud platform. 🚀