This project is a full-stack application with a frontend and a backend. It supports both development and production environments using Docker and Docker Compose.
The application is designed for flexibility, with clear scripts and configurations for managing the lifecycle of the app in different environments.
- Frontend:
- Built with Node.js.
- Runs a development server or builds production assets.
- Backend:
- Also built with Node.js.
- Supports hot-reloading in development mode.
- Dockerized Environment:
- Development and production workflows managed with Docker Compose.
- Environment-specific behavior controlled by
NODE_ENV.
- Docker (version 20.10+ recommended)
- Docker Compose (version 1.29+ recommended)
-
Clone the repository:
git clone https://github.com/your-repo/wake-on-lan.git cd wake-on-lan -
Ensure Docker is installed and running:
-
Make the
start.shscript executable:chmod +x start.sh
To start the application in development mode:
./start.sh- Default environment is
dev. - Services run in attached mode (logs will be displayed in the terminal).
- Frontend is available at: http://localhost:3000.
- Backend uses
hostnetworking and can be accessed at the appropriate endpoint.
To run in detached mode (background):
./start.sh dev trueTo start the application in production mode:
./start.sh prod- Default behavior is detached mode (services run in the background).
- To run in attached mode for production:
./start.sh prod false
Stop all running containers and clean up:
docker-compose down --remove-orphans.
├── docker-compose.yml # Unified Compose file for dev and prod
├── start.sh # Script to manage dev and prod environments
├── frontend/ # Frontend source code
│ ├── Dockerfile # Dockerfile for the frontend
│ ├── package.json # Node.js dependencies for frontend
│ └── ... # Additional frontend files
├── backend/ # Backend source code
│ ├── Dockerfile # Dockerfile for the backend
│ ├── package.json # Node.js dependencies for backend
│ └── ... # Additional backend files
To view logs for all services:
docker-compose logs -fTo view logs for a specific service (e.g., frontend):
docker-compose logs -f frontendThe environment is controlled via the NODE_ENV variable:
- Development: Default behavior. Includes hot-reloading and mapped volumes for code changes.
- Production: Optimized for performance, with frontend assets served by the backend.
- Frontend:
- React
- TypeScript
- Testing Library
- Prettier
- ESLint
- Backend:
- Node.js
- Express
- TypeScript
- Winston (for logging)
- Jest (for testing)
- Prettier
- ESLint
.
├── backend/
│ ├── src/
│ │ ├── config.ts
│ │ ├── routes/
│ │ │ ├── logs.ts
│ │ │ ├── pcs.ts
│ │ │ ├── status.ts
│ │ │ ├── wake.ts
│ │ ├── server.ts
│ │ ├── services/
│ │ │ ├── statusCheckService.ts
│ │ │ ├── wolService.ts
│ │ ├── tests/
│ │ │ ├── statusCheckService.test.ts
│ │ │ ├── wolService.test.ts
│ │ ├── types.ts
│ │ ├── utils/
│ │ │ ├── logger.ts
│ ├── package.json
│ ├── tsconfig.json
├── frontend/
│ ├── src/
│ │ ├── App.css
│ │ ├── App.test.tsx
│ │ ├── App.tsx
│ │ ├── config.ts
│ │ ├── index.css
│ │ ├── index.tsx
│ │ ├── logo.svg
│ │ ├── reportWebVitals.ts
│ │ ├── styles.ts
│ │ ├── utils/
│ │ │ ├── logger.ts
│ ├── package.json
│ ├── tsconfig.json
├── docker-compose.yml
├── start.sh
To run tests for the backend:
cd backend
npm run testTo run tests for the frontend:
cd frontend
npm run test-
Permission Denied for Docker Socket:
- Ensure your user is in the
dockergroup:sudo usermod -aG docker $USER - Log out and back in for the changes to take effect.
- Ensure your user is in the
-
Containers Fail to Start:
- Check logs for errors:
docker-compose logs -f
- Check logs for errors:
-
Rebuild Images:
- If changes to dependencies or Dockerfiles are not picked up:
docker-compose build --no-cache
- If changes to dependencies or Dockerfiles are not picked up:
-
Clean Up Orphaned Containers:
- If containers persist after stopping:
docker-compose down --remove-orphans
- If containers persist after stopping:
Feel free to open issues or submit pull requests for improvements.
This project is licensed under the MIT License.