Skip to content

Commit

Permalink
Add script to update README file
Browse files Browse the repository at this point in the history
  • Loading branch information
Cdaprod committed Feb 12, 2024
1 parent 7f18050 commit 671a1ff
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/scripts/update_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re

def read_file(filename):
with open(filename, 'r', encoding='utf-8') as file:
return file.read()

def write_file(filename, content):
with open(filename, 'w', encoding='utf-8') as file:
file.write(content)

def update_readme(directory_tree, readme_contents):
# Define the start and end markers
start_marker = "<!-- DIRECTORY_TREE_START -->"
end_marker = "<!-- DIRECTORY_TREE_END -->"

# Define the pattern to find the existing directory tree section
pattern = re.compile(re.escape(start_marker) + ".*?" + re.escape(end_marker), re.DOTALL)

# Define the replacement content, including the markers
replacement = f"{start_marker}\n```\n{directory_tree}\n```\n{end_marker}"

# Perform the replacement
updated_contents = re.sub(pattern, replacement, readme_contents)

return updated_contents

directory_tree = read_file('DIRECTORY_TREE.txt')
readme_contents = read_file('README.md')
updated_readme = update_readme(directory_tree, readme_contents)
write_file('README.md', updated_readme)
48 changes: 48 additions & 0 deletions .github/workflows/update_readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Update README with Directory Tree

on:
push:
branches:
- main # or your default branch

jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false # avoids persisting GitHub credentials

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install tree command or alternative
run: |
sudo apt-get update
sudo apt-get install -y tree
- name: Generate Directory Tree
run: |
tree -I '.git|node_modules|other-directories-to-exclude' > DIRECTORY_TREE.txt
- name: Update README.md
run: python .github/scripts/update_readme.py

- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "Cdaprod"
git add README.md
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -m "Automated README update: directory tree"
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}
branch: ${{ github.ref }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.env
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,96 @@

#### Workflow Status Badges:
[![Docker-Compose Build Test](https://github.com/Cdaprod/minio-weaviate/actions/workflows/docker-compose-build-test.yml/badge.svg)](https://github.com/Cdaprod/minio-weaviate/actions/workflows/docker-compose-build-test.yml)

## Current Directory Tree Structure
The following directory tree is programatically generated to provide an overview of the repos structure (by using `.github/workflows/update_readme.yml` and `.github/scripts/update_readme.py` and is ran on `push` to `main`):

<!-- DIRECTORY_TREE_START -->
<!-- DIRECTORY_TREE_END -->

## Introduction
This project serves as a template for building [specific type of projects] with a pre-configured setup including `/app/`, `/minio/`, and `/weaviate/` directories.

## How to Use This Template
To start a new project based on this template:

1. Click the "Use this template" button on the GitHub repository page.
2. Choose a name for your new repository and select "Create repository from template".
3. Clone your new repository to your local machine and begin customizing.

## Configuration
- **App**: Instructions on configuring the `/app/` directory.
- **Minio**: Steps to set up the `/minio/` directory.
- **Weaviate**: Guidelines for initializing the `/weaviate/` component.

Based on the available information from the MinIO and Weaviate documentation, here are the specific commands and configurations for setting up MinIO and Weaviate using Dockerfile and `entrypoint.sh`. However, the exact details for MinIO were not found in the recent search, so I'll provide a general approach based on common practices.

### MinIO Setup using Dockerfile and entrypoint.sh

To configure a MinIO server using Docker, you typically start by creating a `Dockerfile` that specifies the MinIO server image and any necessary environment variables. The `entrypoint.sh` script is used to customize the startup behavior of the MinIO server.

#### Dockerfile for MinIO

```Dockerfile
FROM minio/minio
COPY entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
```

#### entrypoint.sh for MinIO

```bash
#!/bin/sh
# Custom startup script for MinIO

# Initialize MinIO server with specified directories or buckets
minio server /data --console-address ":9001"
```

You may need to adjust the `minio server` command with additional flags or environment variables as per your configuration requirements, such as enabling TLS, setting access and secret keys, etc.

### Weaviate Setup using Dockerfile and entrypoint.sh

The Weaviate documentation provides insights into running Weaviate with Docker, including using `docker-compose` for orchestrating multiple services. For a single-node setup or development purposes, you can encapsulate the configuration in a Dockerfile and an entrypoint script.

#### Dockerfile for Weaviate

```Dockerfile
FROM semitechnologies/weaviate
COPY entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
```

#### entrypoint.sh for Weaviate

```bash
#!/bin/bash
# Custom startup script for Weaviate

# Start Weaviate with a specific configuration
# You can customize this command based on your setup requirements
weaviate start -d
```

In practice, you'd replace `weaviate start -d` with the actual command to start Weaviate, configuring it with environment variables or command-line options as needed for your application. Since Weaviate's setup can vary significantly based on modules and integrations, refer to the [Weaviate documentation](https://weaviate.io/developers/weaviate/current/) for specific configuration details.

### General Notes

- Ensure that both `entrypoint.sh` scripts are executable (`chmod +x entrypoint.sh`) before building your Docker images.
- Adapt the MinIO and Weaviate commands in the `entrypoint.sh` scripts according to your specific needs, such as configuring network settings, security parameters, or enabling specific modules.
- For both services, you might need to configure network settings in `docker-compose.yml` if you're orchestrating multiple containers to ensure they can communicate with each other and with any dependent services.

Remember to consult the official MinIO and Weaviate documentation for the most up-to-date and detailed setup instructions, as configurations can change with new software versions.

## Accessing Specific Versions

To clone a specific version of this project, use the following command, replacing `tag_name` with the desired version tag:

```bash
git clone --branch tag_name --depth 1 https://github.com/cdaprod/minio-weaviate-langchain.git
```

## Contributing
We welcome contributions! Please read our contributing guidelines on how to propose changes.

0 comments on commit 671a1ff

Please sign in to comment.