This guide will help you set up and run the MealMatters application using Docker and Docker Compose. It includes instructions for installing Docker on various operating systems, setting up the project, and running the application.
-
Update your package index:
sudo apt-get update
-
Install Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io
-
Verify the installation:
sudo docker run hello-world
For detailed instructions, visit the Docker installation guide for Linux.
- Download Docker Desktop for Windows from the official Docker website.
- Run the installer and follow the instructions.
- Start Docker Desktop from your applications or programs menu.
- Download Docker Desktop for Mac from the official Docker website.
- Open the downloaded file and drag the Docker icon to your Applications folder.
- Start Docker Desktop from your Applications folder.
Docker Compose should be automatically installed with Docker Desktop for Windows and macOS. For Linux, follow the instructions at Install Docker Compose.
Ensure your project directory is structured as follows:
MealMatters/
│
├── client/ # Frontend source files
│ ├── (frontend files)
│ └── package.json
│
├── server/ # Backend source files
│ ├── (backend files)
│ └── package.json
│
├── Dockerfile-frontend # Dockerfile for the frontend
├── Dockerfile-backend # Dockerfile for the backend
├── docker-compose.yml # Docker Compose file
└── startup.sh # Startup script for the backend
Set up Dockerfile-frontend
, Dockerfile-backend
, docker-compose.yml
, and startup.sh
as previously outlined.
-
Build and Run with Docker Compose: In your project's root directory, run:
docker-compose up --build
-
Accessing the Application:
- The frontend is available at
http://localhost:5173
. - The backend API is at
http://localhost:5000
.
- The frontend is available at
-
Stopping the Application: To stop, press
Ctrl+C
. To remove containers, run:docker-compose down
- JWT Secret: Generated dynamically by
startup.sh
on each container start. Previous JWT tokens become invalid after each restart
.
- Data Persistence: MongoDB data persists in a Docker volume as defined in
docker-compose.yml
. - Security: Handle sensitive information carefully, especially in production.
This guide provides a comprehensive overview of setting up and running the MealMatters application using Docker and Docker Compose. For more information or troubleshooting, refer to the Docker documentation.