π A comprehensive Docker-based development environment for modern JavaScript frameworks with intelligent port detection and multi-framework support. This template provides a containerized setup that ensures consistent development environments across different machines while automatically configuring ports based on your chosen framework.
- π³ Docker-based development environment - Consistent setup across all machines
- π§ Intelligent framework detection - Automatically detects and configures your framework
- βοΈ Multiple framework support:
- Next.js (App Router) - Port 3000
- React (with React Router v7) - Port 5173
- Expo (React Native) - Port 8081
- Vue.js - Port 5173
- Vite - Port 5173
- Custom frameworks - Port 8080
- π― Smart port management - No manual port configuration needed
- π§ Make-based workflow - Simple commands for all operations
- οΏ½ Hot reload support - Instant development feedback
- π€ Non-root user setup - Secure container execution
- π¦ Volume mounting - Persistent development files
- π οΈ Extensible architecture - Easy to add new frameworks
Zero configuration required! The template automatically detects your framework and configures the appropriate ports:
Framework | Default Port | Detection Method | Status |
---|---|---|---|
Next.js | 3000 | "next" dependency | β Fully Supported |
Expo | 8081 | "expo" or "@expo/" | β Fully Supported |
React | 5173 | "react" (without Next.js) | β Fully Supported |
Vue.js | 5173 | "vue" dependency | β Fully Supported |
Vite | 5173 | "vite" dependency | β Fully Supported |
Custom | 8080 | Unknown framework | β
Supported via init-framework |
When you run make up
, the system will:
- π Scan your
package.json
for framework dependencies - π Detect the framework type automatically
- βοΈ Configure appropriate ports without manual intervention
- π Start your development server with the correct configuration
Example output:
$ make up Detected framework: next (port: 3000) Using ports: Host: 3000 -> Container: 3000 Soon your project will be available at http://localhost:3000
git clone <repository-url> cd react-dockerized
Edit the .env
file to customize your project settings:
IMAGE_NAME=frontend-dockerized-app PROJECT_NAME=my_project NODE_ENV=development
Choose one of the predefined frameworks:
For Next.js (recommended for web apps):
make init-next
For React Router (traditional React apps):
make init-react
For Expo (React Native apps):
make init-expo
For Vue.js applications:
make init-vue
For Vite applications:
make init-vite
make up
Navigate to the automatically detected port in your browser (depending on your framework).
For frameworks not directly supported, use the init-framework
command with a custom create command:
make init-framework CREATE_COMMAND="<your-custom-command>"
Create a Svelte application:
make init-framework CREATE_COMMAND="npm create svelte@latest my_project"
Create a Remix application:
make init-framework CREATE_COMMAND="npx create-remix@latest my_project"
Create a Nuxt.js application:
make init-framework CREATE_COMMAND="npx nuxi@latest init my_project"
Note: Custom frameworks will default to port 8080. The development server will be available at http://localhost:8080.
Run make help
to see all available commands with descriptions.
# Install packages make npm install lodash # Install dev dependencies - note about double `--`! make npm install typescript -- --save-dev # Run custom scripts make npm run build # Check versions make npm list
-
Initialize your project:
make init-next # or any other supported framework
-
Start development:
make up
-
Install additional packages:
make npm install <package-name>
-
Run custom npm scripts:
make npm run <script-name>
-
Access container for debugging:
make shell
-
Stop development:
make down
After initialization, your project will have the following structure:
react-dockerized/ βββ .env # Environment configuration βββ compose.yaml # Docker Compose services βββ Dockerfile # Container definition βββ Makefile # Development commands βββ LICENSE # MIT License βββ README.md # This file βββ docker/ # Docker utilities β βββ detect-framework.sh # Framework detection script β βββ entrypoint.sh # Container startup script β βββ port-config.sh # Port configuration logic βββ <your-project>/ # Your application (created after init) βββ package.json βββ src/ βββ ... (framework-specific files)
Variable | Description | Default Value |
---|---|---|
IMAGE_NAME | Docker container name | react-dockerized-app |
PROJECT_NAME | Directory name for your project | my_project |
NODE_ENV | Node.js environment | development |
PORT_HOST | Host port (auto-detected) | Framework-dependent |
PORT_CONTAINER | Container port (auto-detected) | Framework-dependent |
Ports are automatically detected, but you can override them by modifying the port mapping in compose.yaml
:
ports: - "3001:${PORT_CONTAINER}" # Change 3001 to your desired host port
When using init-framework
with custom commands, the system will:
- Use port 8080 as default for unknown frameworks
- Attempt to detect the framework from the generated
package.json
- Update port configuration accordingly after detection
If you encounter permission issues, the Dockerfile creates a non-root user with UID 1000. Make sure your host user has the same UID or adjust the Dockerfile accordingly:
# Check your UID id -u # If different from 1000, modify Dockerfile: # ARG USER_UID=<your-uid>
-
Check if the port is already in use:
lsof -i :3000 # or your framework's port
-
Ensure Docker is running:
docker --version docker compose version
-
Check container logs:
docker logs react-dockerized-app
If the project directory doesn't exist, run one of the init commands first:
make init-next # or init-react, init-expo, init-vue, init-vite
If your framework isn't detected properly:
-
Check if the framework dependency is in
package.json
-
Try rebuilding with framework detection:
make build-smart
-
For custom frameworks, ensure your command creates a valid
package.json
We welcome contributions to improve this template! Here's how you can help:
For detailed contributing guidelines, see CONTRIBUTING.md.
This project is open source and available under the MIT License. See the LICENSE file for the full license text.
You are free to:
- β Use this project commercially
- β Modify and distribute
- β Include in private projects
- β Use for educational purposes
Happy coding! π
If you find this template helpful, please consider giving it a β!