Skip to content

Commit

Permalink
Merge branch 'AOSSIE-Org:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushyantbha012 authored Dec 30, 2024
2 parents abe4520 + 65c2560 commit 2c6977a
Show file tree
Hide file tree
Showing 16 changed files with 484 additions and 295 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ Handles file system operations and provides a secure bridge between the frontend

#### Installation


1. Clone the repository to your local system:
```bash
git clone [email protected]:AOSSIE-Org/PictoPy.git
```
```bash
cd PictoPy
```


1. Navigate to the frontend directory:
```bash
cd frontend
Expand Down Expand Up @@ -232,6 +242,9 @@ The server will start on `http://localhost:8000` by default. In test mode, the s
You can control the number of workers by setting the `WORKERS` environment variable before running the script. If not set, it defaults to 1 worker.
### Docker Compose Setup
- [Docker Compose](./docs/docker-compose/redme.md)
### Setup using Dockerfile
- For setting up the frontend, follow the instructions in the [Frontend Setup Guide](./docs/frontend/docker-setup.md).
Expand Down
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ RUN pip install --no-cache-dir -r requirements.txt

COPY . /app/

RUN chmod +x run.sh && mkdir -p ../images

RUN chmod +x run.sh
RUN ls app
EXPOSE 8000
ENV WORKERS=1

Expand Down
2 changes: 1 addition & 1 deletion backend/app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
TEST_INPUT_PATH = "tests/inputs"
TEST_OUTPUT_PATH = "tests/outputs"

IMAGES_PATH = "../images"
IMAGES_PATH = "./images"

IMAGES_DATABASE_PATH = "app/database/images.db"
ALBUM_DATABASE_PATH = "app/database/albums.db"
Expand Down
Binary file added backend/images/PictoPy_Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: pictopy

services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: frontend-container
network_mode: host
ports:
- "1420:1420"
environment:
- DISPLAY=${DISPLAY}
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
- images-data:/app/images
- /:/host
stdin_open: true
tty: true

backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: backend-container
ports:
- "8000:8000"
volumes:
- images-data:/app/images
- /:/host

volumes:
frontend-data:
images-data:

211 changes: 107 additions & 104 deletions docs/backend/docker-setup.md
Original file line number Diff line number Diff line change
@@ -1,104 +1,107 @@
# Backend Docker Setup for PictoPy

This guide provides step-by-step instructions for building and running the PictoPy backend using Docker.

## Table of Contents

1. [Prerequisites](#prerequisites)
2. [Building the Docker Image](#building-the-docker-image)
3. [Running the Docker Container](#running-the-docker-container)
4. [Verifying the Container](#verifying-the-container)
5. [Accessing the Application](#accessing-the-application)
6. [Stopping the Container](#stopping-the-container)
7. [Troubleshooting](#troubleshooting)

## Prerequisites

Before you begin, ensure you have the Docker installed on your machine

- Verify the installation by running:
```bash
docker --version
```

## Building the Docker Image

1. Open a terminal and navigate to your project's root directory.

2. Go to Backend directory

```bash
cd backend
```

3. Run the following command to build the Docker image, replacing `<image_name>` with your desired image name:

```bash
docker build -t <image_name> .
```

4. Wait for the build process to complete. This may take a few minutes depending on your internet speed and system performance.

## Running the Docker Container

Once the image is built, you can run a container using the following command:

```bash
docker run -d -p 8000:8000 --name <container_name> <image_name>
```

- `-d`: Runs the container in detached mode (in the background).
- `-p 8000:8000`: Maps port 8000 on the host to port 8000 in the container.
- `--name <container_name>`: Names the container for easier management.
- `<image_name>`: Specifies the image to use (the one we just built).

## Verifying the Container

To check if the container is running:

```bash
docker ps
```

You should see an entry for `<container_name>` with the status `Up`.

## Accessing the Application

Open a web browser or frontend to access the application at:

```
http://localhost:8000
```

## Stopping the Container

If you need to stop the container:

```bash
docker kill <container_id>
```

## Troubleshooting

1. **Port already in use**: If you get an error saying the port is already in use, you can either:

- Stop the process using port 8000, or
- Change the port mapping in the `docker run` command (e.g., `-p 8001:8000`)

2. **Container exits immediately**: Check the container logs:

```bash
docker logs <container_name>
```

3. **Permission issues**: Ensure that `run.sh` has execute permissions(for linux only):

```bash
chmod +x run.sh
```

Then rebuild the Docker image.

Remember to rebuild your Docker image (`docker build -t <image_name> .`) after making any changes to your application or Dockerfile.

For more advanced Docker usage , view the [Docker documentation](https://docs.docker.com/get-started/).
# Backend Docker Setup for PictoPy

This guide provides step-by-step instructions for building and running the PictoPy backend using Docker.

## Table of Contents

1. [Prerequisites](#prerequisites)
2. [Building the Docker Image](#building-the-docker-image)
3. [Running the Docker Container](#running-the-docker-container)
4. [Verifying the Container](#verifying-the-container)
5. [Accessing the Application](#accessing-the-application)
6. [Stopping the Container](#stopping-the-container)
7. [Troubleshooting](#troubleshooting)

## Prerequisites

Before you begin, ensure you have the Docker installed on your machine

- Verify the installation by running:
```bash
docker --version
```

## Building the Docker Image

1. Open a terminal and navigate to your project's root directory.

2. Go to Backend directory

```bash
cd backend
```

3. Run the following command to build the Docker image, replacing `<image_name>` with your desired image name:

```bash
docker build -t <image_name> .
```

4. Wait for the build process to complete. This may take a few minutes depending on your internet speed and system performance.

## Running the Docker Container

Once the image is built, you can run a container using the following command:

```bash
docker run -it --name backend-container -p 8000:8000 \
-v images-data:/app/images \
-v /:/host \
<image-name>
```

- `-it`: Runs the container interactively, attaching to the terminal for input/output.
- `-p 8000:8000`: Maps port 8000 on the host to port 8000 in the container.
- `-v`: Mounts a volume to share data between the host and container.
- `<image_name>`: Specifies the image to use (the one we just built).

## Verifying the Container

To check if the container is running:

```bash
docker ps
```

You should see an entry for `<container_name>` with the status `Up`.

## Accessing the Application

Open a web browser or frontend to access the application at:

```
http://localhost:8000
```

## Stopping the Container

If you need to stop the container:

```bash
docker kill <container_id>
```

## Troubleshooting

1. **Port already in use**: If you get an error saying the port is already in use, you can either:

- Stop the process using port 8000, or
- Change the port mapping in the `docker run` command (e.g., `-p 8001:8000`)

2. **Container exits immediately**: Check the container logs:

```bash
docker logs <container_name>
```

3. **Permission issues**: Ensure that `run.sh` has execute permissions(for linux only):

```bash
chmod +x run.sh
```

Then rebuild the Docker image.

Remember to rebuild your Docker image (`docker build -t <image_name> .`) after making any changes to your application or Dockerfile.

For more advanced Docker usage , view the [Docker documentation](https://docs.docker.com/get-started/).
Loading

0 comments on commit 2c6977a

Please sign in to comment.