KassiesRecipies is a web application built using Next.js that allows users to explore and manage recipes. This README will guide you through setting up the project, running it in development mode, building the production version, deploying the app using Docker, and creating and transferring a Docker image tarball.
- Prerequisites
- Setting Up the Development Environment
- Running the Development Server
- Building the Production Version
- Deploying the App Using Docker
- Creating and Transferring a Docker Image Tarball
- Environment Variables
Before you start, make sure you have the following installed on your system:
- Node.js (v22 or higher)
- Docker (for containerization)
- MongoDB (if you're running the database locally)
-
Clone the repository:
git clone git@github.com:VilSoft/KassiesRecipies.git cd KassiesRecipies -
Install dependencies:
npm install
-
Create a
.env.localfile in the root of the project and configure your environment variables (e.g., MongoDB connection string, etc.).
npm run testTo run the app in development mode, use the following command:
npm run devThis will start the development server at http://localhost:3000. You can open this URL in your browser to view the app.
To build the production version of the app, run:
npm run buildThis command generates the .next directory, which contains the optimized version of the app. After building, you can run the production version with:
npm run startThis will start the app in production mode at http://localhost:3000.
-
Build the Docker image for the app:
docker build -t kassiesrecipies:latest .This will create a Docker image named
kassiesrecipies:latest.
-
Run the app as a Docker container:
docker run -p 3000:3000 kassiesrecipies:latest
The app will be available at
http://localhost:3000within the container.
-
Build the Docker image targeting the
linux/arm64/v8architecture (for Raspberry Pi):docker buildx build --platform linux/arm64/v8 -t kassiesrecipies:latest --load .
-
Save the image as a tarball for transfer:
docker save -o kassiesrecipies-arm64.tar kassiesrecipies:latest
This will generate the
kassiesrecipies-arm64.tarfile.
-
Transfer the tarball to your Raspberry Pi:
scp kassiesrecipies-arm64.tar pi@<your-pi-ip>:/home/pi/
-
SSH into your Raspberry Pi:
ssh pi@<your-pi-ip>
-
Load the Docker image:
docker load -i /home/pi/kassiesrecipies-arm64.tar
-
Run the app as a Docker container on the Raspberry Pi:
docker run --network host -p 3000:3000 --restart always kassiesrecipies:latest
The
--restart alwayswill ensure that the container will start on boot/crash
The app will be available at http://localhost:3000 on your Raspberry Pi.
Make sure to configure the following environment variables in your .env.local file:
MONGODB_URI: MongoDB connection string (e.g.,mongodb://localhost:27017/yourdb).
This guide covered the basic steps for setting up the development environment, building the app for production, deploying it with Docker, and transferring the Docker image as a tarball for deployment on a Raspberry Pi. You should now be able to run the app locally and on your Pi with ease.
Let me know if you need further assistance or run into any issues!