Setting up an Expo project using Bun and Dockerizing it so that other developers can work in a consistent environment is a great idea. Below is a step-by-step guide to do this in the most straightforward way.
✅ Goals
- Use Bun as the runtime (instead of Node.js)
- Use Expo for the React Native app
- Create a Dockerized development environment
- Allow other devs to run the same setup via Docker
🛠️ Step-by-Step Guide
1. Create the Expo Project
You can start by creating your Expo project locally using Bun:
bun create expo@latest my-app
cd my-app
This creates a standard Expo project structure using bun install under the hood.
2. Add Docker Support
Now we’ll add Docker support to allow others to run the project in a container with Bun installed.
📁 File Structure Overview
Your project should look like this:
my-app/
├── Dockerfile
├── docker-compose.yml
├── app/
├── src/
├── App.tsx
├── package.json
├── bun.lockb
└── ...
3. Create Dockerfile
Create a file named Dockerfile at the root of your project:
# Use a base image with Bun pre-installed
FROM oven/bun:1.0
# Set working directory inside container
WORKDIR /app
# Copy package files first to leverage layer caching
COPY package.json .
COPY bun.lockb ./
# Install dependencies with Bun
RUN bun install
# Copy the rest of the source code
COPY . .
# Expose ports needed by Expo CLI
EXPOSE 8081 19000 19001 19002
# Start the Expo dev server
CMD ["bun", "expo", "start"]
4. Create docker-compose.yml
This makes it easier to manage ports, volumes, and restart policies.
version: '3.8'
services:
expo:
build: .
ports:
- "8081:8081"
- "19000:19000"
- "19001:19001"
- "19002:19002"
volumes:
- .:/app
- expo-node-modules:/app/node_modules
environment:
- EXPO_USE_BUN=true
stdin_open: true
tty: true
restart: unless-stopped
volumes:
expo-node-modules:
Note: We're mounting node_modules into a volume to avoid conflicts between host and container node modules.
5. Build and Run the Container
From the project root:
docker-compose up --build
This will:
- Build the image with Bun
- Install all dependencies
- Start the Expo development server
You can now access the Expo Dev Tools at http://localhost:19002.
6. Share the Environment
Other developers can just clone your repo and run:
docker-compose up
No need to install Node.js, Bun, or even Expo CLI locally — everything runs inside the container.
🧪 Optional: Add Scripts to package.json
You can make life easier by adding some scripts:
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"docker:start": "docker-compose up"
}
Then run:
bun run docker:start
🚨 Known Limitations
- Hot Module Reloading (HMR) may not work perfectly if you're editing files outside the container.
- If you're on Windows, ensure Docker Desktop is running and WSL2 integration is enabled.
- Some native features may require extra configuration depending on the platform.
✅ Summary
| Task | Command |
|---|
| Create Expo project | bun create expo@latest my-app |
| Build Docker image | docker-compose build |
| Run the app | docker-compose up |
| Stop the app | docker-compose down |
🎉 You're Done!
Now you have a fully Dockerized Expo project using Bun, and any developer can join the project without needing to set up a local JavaScript environment.
Let me know if you want Android/iOS device debugging instructions inside Docker too!