This project sets up a development environment using Docker for four popular frontend frameworks: React, Vue, Angular, and Svelte. Each framework is configured with its own service in Docker, allowing you to quickly spin up isolated development environments.
This project defines the following services in a docker-compose.yml
file:
React
./react/src
folder to /workspace
in the container.Vue
./vue/src
folder to /workspace
in the container.Angular
./angular/src
folder to /workspace
in the container.Svelte
./svelte/src
folder to /workspace
in the container.git clone https://github.com/amirwhocode/swarm.git
cd swarm
docker-compose build --no-cache
docker-compose up
There are two ways to create a React app. The create-react-app
command is already installed in the container, and you can use this to create a new React app:
create-react-app
command:create-react-app <project-name>
npm create vite@latest
vue create <project-name>
cd <project-name>
npm run serve
npm create vue@latest
cd <your-project-name>
npm install
npm run dev
npm init quasar@latest
cd <your-project-name>
quasar dev
ng new <project-name>
cd <project-name>
ng serve --host 0.0.0.0
npx sv create <project-name>
cd <project-name>
npm install
npm run dev
If you're using Vite to create a React app, you may encounter issues accessing the app from your host browser. To fix this, you need to update the vite.config.ts
file to ensure the server is accessible outside the container.
vite.config.ts
:
Open the vite.config.ts
file in your React project and add or modify the server configuration:
```
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';export default defineConfig({ plugins: [react()], server: { host: '0.0.0.0', // Allows access from outside the container port: 5173, // Explicitly setting the port (not strictly necessary but good practice) } })
```
By default, development servers (e.g., Angular, React) bind to localhost (127.0.0.1), making the app accessible only within the container, not from the host.
Binding to localhost restricts access to the container. To access the app from the host, the server needs to listen on all network interfaces (0.0.0.0).
Temporary fix: Run the app with --host 0.0.0.0 (e.g., ng serve --host 0.0.0.0 or npm start --host 0.0.0.0).
Modify your framework's config to bind to 0.0.0.0 by default (e.g., "host": "0.0.0.0" in angular.json or "HOST": "0.0.0.0" in .env for React).
Binding to 0.0.0.0 allows the server to accept connections from both the container and the host machine.