Skip to content

Commit

Permalink
Merge pull request #17 from whykay-01/yan-dev
Browse files Browse the repository at this point in the history
added .env for the password management
  • Loading branch information
whykay-01 authored Jul 24, 2023
2 parents 96ce6a1 + 101d944 commit 28f9320
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 76 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ virtual-assistant/logs/
virtual-assistant/langflow.db
loaning-system/app/__pycache__
original-datasources/
testing-data.csv
testing-data.csv
loaning-system/venv
.env
1 change: 1 addition & 0 deletions loaning-system/.env.exmaple
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ADMIN_ACCESS_TOKEN = "YOUR_MD5ed_TOKEN"
4 changes: 3 additions & 1 deletion loaning-system/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ FROM python:3.11
ADD dashboard.py .
ADD app/ ./app
ADD templates/ ./templates
ADD .env .
# installing dependencies
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir --upgrade -r ./requirements.txt

# exposing the port we need
EXPOSE 8050
CMD ["python", "./dashboard.py"]
80 changes: 75 additions & 5 deletions loaning-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,46 @@ In additional to the "invisible difference," I have added the following features

# Quickstart Guide on Dockerizing the Loaning System Dashboard

##### NOTE: Please run the follwing commands in the terminal to ensure that you have Docker installed on your system:
Prereqs: Homebrew package manager for Mac OS/Linux and Linux system

```
### NOTE: Please run the following commands in the terminal to ensure that you have Docker installed on your system:

```bash
brew update
brew install docker
```

### NOTE: This is the guide for the Mac users.

Before we start, it is important to move to the working directory:

```
```bash
cd loaning-system
```

Here is the command which will get you started:
To deploy, please modify the .env file first. You have to change `ADMIN_ACCESS_TOKEN` to the md5-ed version of your password. To do so, please run the following command in the terminal:

```bash
echo -n "YOUR_PASSWORD" | md5
```

Then copy the hashed version of your password, and run the follwing command:

Create .env file from example.env and change the values

```bash
cp example.env .env
```

Now, set the `ADMIN_ACCESS_TOKEN` to the hashed version of your password which we copied earlier. To do this, run the following command:

```bash
vim .env
```

Or simply open the newly created `.env` file in your favorite text editor and change the value of `ADMIN_ACCESS_TOKEN` to the hashed version of your password.

After the environment variables are set, run the following command to deploy the system:

```bash
docker compose up -d --build
Expand All @@ -49,4 +75,48 @@ docker compose logs -f

Click [here](https://drive.google.com/file/d/1UKXMfQVqtk0NGlanh6DNLxfgmebsqEZ0/view?usp=sharing) to see the video demonstration of the system.

docker run -d -v /Users/yan/git-repos/capacity-management/loaning-system/data:/data whykay01/loaning-system-image:2.0.0
# How did I add the image to the server?

1. I have created a Dockerfile in the root directory of the project.

2. I have created a docker image using the following command:

```bash
docker build -t dashboard-image .
```

3. I tagged the image using the following command:

```bash
docker tag dashboard-image whykay01/loaning-system
```

4. I have pushed the image to the docker hub using the following command:

```bash
docker push whykay01/loaning-system
```

# Now to run the files, you have to run the following commands:

```bash
docker pull whykay01/loaning-system
```

```bash
docker run -d -p 8050:8050 -v <YOUR_PATH_TO_THE_DATA_FOLDER>:/data --name dashboard_container whykay01/loaning-system
```

in this example: `/Users/yan/git-repos/capacity-management/loaning-system/data` is the path to my data file, however, you have to change it to your path to the data file.

```bash
docker logs -f dashboard_container
```

```bash
docker stop dashboard_container
```

```bash
docker start dashboard_container
```
2 changes: 1 addition & 1 deletion loaning-system/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ def test_generate_main_db(path, filename):
return [equipment_cycle, user_cycle, unique_user_equipment, non_unique_user_equipment]

except Exception as e:
return True
return False
Loading

0 comments on commit 28f9320

Please sign in to comment.