Skip to content

Commit e373065

Browse files
committed
Docker compose working correctly
1 parent 498eebe commit e373065

9 files changed

Lines changed: 158 additions & 9998 deletions

File tree

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
npm-debug.log
3+
Dockerfile
4+
.dockerignore

README.md

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,121 @@
1-
# CHLOD
1+
# CHLOD (Cultural Heritage Linked Open Data)
2+
3+
## Overview
4+
CHLOD is a structured schema based on CIDOC CRM to represent Nepal's cultural heritage data. This project facilitates standardized data representation and interoperability for cultural heritage datasets.
5+
6+
## Getting Started
7+
8+
### Prerequisites
9+
- [Docker](https://docs.docker.com/get-docker/)
10+
- [Docker Compose](https://docs.docker.com/compose/install/)
11+
12+
### Running the Application
13+
14+
1. Clone the repository:
15+
```bash
16+
git clone <repository-url>
17+
cd chlod
18+
```
19+
20+
2. Start the application using Docker Compose:
21+
```bash
22+
docker-compose up -d
23+
```
24+
25+
3. The application should now be running at:
26+
- **Frontend**: [http://localhost:3000](http://localhost:3000)
27+
- **Backend API**: [http://localhost:8000](http://localhost:8000)
28+
29+
### Stopping the Application
30+
31+
To stop the application and remove the containers:
32+
```bash
33+
docker-compose down
34+
```
35+
36+
To stop the application while preserving the containers:
37+
```bash
38+
docker-compose stop
39+
```
40+
41+
### Viewing Logs
42+
43+
To view the logs of all containers:
44+
```bash
45+
docker-compose logs
46+
```
47+
48+
To follow the logs in real-time:
49+
```bash
50+
docker-compose logs -f
51+
```
52+
53+
## Accessing the Site
54+
55+
### Frontend
56+
The frontend service is running on port 3000. You can access it by navigating to:
57+
```
58+
http://localhost:3000
59+
```
60+
61+
### Backend
62+
The backend service is running on port 8000. You can access it by navigating to:
63+
```
64+
http://localhost:8000
65+
```
66+
67+
## Docker Containers
68+
69+
To check the status of the Docker containers, you can use the following command:
70+
```sh
71+
docker ps
72+
```
73+
74+
This will show you the running containers and their respective ports.
75+
76+
## Directory Structure
77+
```
78+
chlod/
79+
├── docker-compose.yml # Docker Compose configuration
80+
├── backend/ # Backend API implementation
81+
├── frontend/ # Frontend application
82+
└── README.md # Project documentation
83+
```
84+
85+
## Contributing
86+
Contributions are welcome! To contribute:
87+
1. Fork the repository.
88+
2. Create a new branch: `git checkout -b feature-branch`
89+
3. Commit your changes: `git commit -m 'Add new feature'`
90+
4. Push to the branch: `git push origin feature-branch`
91+
5. Submit a pull request.
92+
93+
## License
94+
This project is licensed under the MIT License. See the `LICENSE` file for details.
95+
96+
## Contact
97+
For any inquiries, reach out via [info@cair-nepal.org](mailto:info@cair-nepal.org).
98+
99+
## Troubleshooting
100+
101+
### Connection Issues
102+
103+
If you encounter connection issues, follow these steps:
104+
105+
1. **Check Docker Container Status**: Ensure that both the frontend and backend containers are running.
106+
```sh
107+
docker ps
108+
```
109+
110+
2. **Check Container Logs**: View the logs of the frontend and backend containers to see if there are any errors.
111+
```sh
112+
docker-compose logs frontend
113+
docker-compose logs backend
114+
```
115+
116+
3. **Restart Docker Containers**: Sometimes restarting the containers can resolve the issue.
117+
```sh
118+
docker-compose restart
119+
```
120+
121+
4. **Check Network Configuration**: Ensure that your firewall or proxy settings are not blocking the connections to ports 3000 and 8000.

backend/Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ ENV PYTHONUNBUFFERED=1
88
# Set the working directory in the container
99
WORKDIR /app/heritage_graph
1010

11-
# Install dependencies
11+
# Install system dependencies and clean up
12+
RUN apt-get update && \
13+
apt-get install -y --no-install-recommends gcc python3-dev && \
14+
rm -rf /var/lib/apt/lists/*
15+
16+
# Install Python dependencies
1217
COPY requirements.txt /app/
13-
RUN pip install --no-cache-dir -r /app/requirements.txt
18+
RUN pip install --no-cache-dir -r /app/requirements.txt && \
19+
rm -rf /root/.cache/pip
1420

1521
# Copy the Django project into the container
1622
COPY . /app/

backend/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
asgiref==3.8.1
22
Django==5.1.3
33
djangorestframework==3.15.2
4+
drf-spectacular
45
sqlparse==0.5.2
56
typing_extensions==4.12.2
67
begins==0.9

docker-compose.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
version: '3.8'
2-
31
services:
4-
backend:
5-
build: ./backend
6-
ports:
7-
- "8000:8000"
8-
volumes:
9-
- ./backend:/app
10-
working_dir: /app/heritage_graph
11-
environment:
12-
- ALLOWED_HOSTS=0.0.0.0,localhost,127.0.0.1
13-
restart: on-failure
14-
152
frontend:
163
build: ./frontend
174
ports:
18-
- "3000:3000" # Map host port 3000 to container port 3000
19-
volumes:
20-
- ./frontend:/app
21-
- /app/node_modules # Avoid overwriting node_modules in the container
5+
- "3000:3000"
6+
depends_on:
7+
- backend
228

23-
# command: npm run start # Use 'npm run build && serve -s build -l 3000' for production
9+
backend:
10+
build: ./backend
11+
ports:
12+
- "8000:8000"

frontend/Dockerfile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,19 @@ FROM node:18-alpine
44
# Set the working directory in the container
55
WORKDIR /app
66

7-
# Copy package.json and package-lock.json
8-
COPY package*.json ./
7+
# Create a non-root user and switch to it
8+
RUN adduser -D myuser
99

10-
# Install dependencies
10+
# Copy package.json and install dependencies
11+
COPY package.json ./
1112
RUN npm install
1213

1314
# Copy the rest of the application code
1415
COPY . .
1516

16-
# Build the application
17-
RUN npm run build
18-
19-
# Install `serve` globally to serve the build files
20-
RUN npm install -g serve
21-
22-
# Expose the port your app runs on (default for `serve` is 3000)
17+
# Expose the port
2318
EXPOSE 3000
2419

25-
# Serve the build files
26-
CMD ["serve", "-s", "build", "-l", "3000"]
20+
# Start the Vite dev server
21+
CMD ["npm", "run", "start", "--", "--host"]
22+

0 commit comments

Comments
 (0)