This is a 'hello world' app with a Node.js backend API and a Vue.js frontend, both running in Docker containers. The app is built to demonstrate API calls and the integration of both services. This repository includes instructions to run the app locally.
- Docker: You need Docker installed to build and run the app containers.
- Node.js: Required for the backend (if you want to run it locally without Docker).
- npm/yarn: Required for installing dependencies for both frontend and backend.
git clone https://github.com/donghao0210/hello-jenkins-nvjs.git
cd hello-jenkins-nvjs
Go to the backend/
folder and install dependencies:
cd backend
npm install
npm start # Runs the backend on http://localhost:3000
Go to the frontend/
folder and install dependencies:
cd frontend
npm install
npm run serve # Runs the frontend on http://localhost:8080
Now, you should be able to access the backend API on http://localhost:3000
and the frontend on http://localhost:8080
.
To run both the backend and frontend using Docker, follow these steps:
Navigate to the root of the repository and build the backend image:
# docker build -t backend-api -f backend/Dockerfile .
docker build -t registry.gnod.lol/backend-api:dev -f backend/Dockerfile .
docker run -d --name backend \
-p 3000:3000 \
--env ENVIRONMENT=dev \
registry.gnod.lol/backend-api:dev
This will build the backend Docker image and start the container, exposing port 3000
.
Similarly, build and run the frontend Docker image:
docker build -t registry.gnod.lol/frontend-app:dev -f frontend/Dockerfile .
docker run -d --name frontend \
-p 3000:3000 \
--env ENVIRONMENT=dev \
registry.gnod.lol/frontend-app:dev
This will build the frontend Docker image and start the container, exposing port 80
.
To check if your containers are running:
docker ps
You should see the backend-api
running on port 3000
and frontend-app
running on port 80
.
Now you can access the frontend on http://localhost
and the backend API on http://localhost:3000
.
- Docker Errors: If you're having issues building or running Docker containers, check if Docker is installed correctly and if your user has the necessary permissions.
- Frontend not loading: If the frontend doesn't load, make sure the backend container is running and accessible at
http://localhost:3000
.