Skip to content

Commit

Permalink
Update: Enhanced Angular frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed Sep 8, 2024
1 parent 85dd658 commit d09ec62
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .idea/Learning-Management-System.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions LMS-Backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use the official Python image as a parent image
FROM python:3.9-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set the working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the project files
COPY . .

# Expose the port
EXPOSE 8000

# Run the Django development server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
28 changes: 28 additions & 0 deletions LMS-Frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:18.19

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json from the Angular app directory
COPY ./app/package*.json ./

# Install Angular CLI globally
RUN npm install -g @angular/cli

# Install frontend dependencies
RUN npm install

# Copy the entire Angular app to the working directory
COPY ./app .

# Build the Angular application for production
RUN ng build --configuration production

# Install a lightweight HTTP server to serve the application
RUN npm install -g http-server

# Expose the port the application will run on
EXPOSE 8080

# Serve the Angular application
CMD ["http-server", "dist/your-angular-app-name", "-p", "8080"]
26 changes: 22 additions & 4 deletions LMS-Frontend/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions LMS-Frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"bootstrap": "^5.3.3",
"chart.js": "^4.4.4",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Welcome to the **E-Learning Management System (LMS)**! This project consists of
- [Testing the APIs](#testing-the-apis)
- [Seeding Sample Data](#seeding-sample-data)
- [Recommended GUI Tools](#recommended-gui-tools)
- [Containerization](#containerization)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -531,6 +532,22 @@ To interact with the APIs and databases more easily, you can use the following G
- **Swagger UI**: An interactive API documentation tool. You can access the Swagger UI at [http://127.0.0.1:8000/swagger/](http://127.0.0.1:8000/swagger/). Ensure the server is running before accessing the UI.
- **Redoc**: Another interactive API documentation tool. You can access the Redoc UI at [http://127.0.0.1:8000/redoc/](http://127.0.0.1:8000/redoc/). Ensure the server is running before accessing the UI.

## Containerization

The project can be containerized using Docker. The `Dockerfile` and `docker-compose.yml` files are provided in the repository. To containerize the project, follow these steps:

1. **Change directory into the project root:**

```bash
cd Learning-Management-System
```

2. **Build the Docker image:**

```bash
docker compose up --build
```

## Troubleshooting

### Common Issues
Expand Down
46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
services:
backend:
build:
context: ./LMS-Backend
dockerfile: Dockerfile
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./LMS-Backend:/app
ports:
- "8000:8000"
depends_on:
- mongodb
- redis
environment:
- MONGO_HOST=mongodb
- MONGO_PORT=27017
- REDIS_HOST=redis
- REDIS_PORT=6379

frontend:
build:
context: ./LMS-Frontend
dockerfile: Dockerfile
ports:
- "8080:8080"
volumes:
- ./LMS-Frontend:/app
stdin_open: true
tty: true

mongodb:
image: mongo:5.0
container_name: mongo
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db

redis:
image: redis:6
container_name: redis
ports:
- "6379:6379"

volumes:
mongodb_data:

0 comments on commit d09ec62

Please sign in to comment.