Skip to content

Commit

Permalink
⚡perf: update seed files
Browse files Browse the repository at this point in the history
  • Loading branch information
blinko-space committed Nov 7, 2024
1 parent 3edef44 commit 1d8e176
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 36 deletions.
Empty file removed .blinko/faiss/.ignore
Empty file.
Empty file removed .blinko/pgdump/.ignore
Empty file.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ public/assets
.blinko/faiss/*
.blinko/pgdump/*
.blinko/files/*
!.blinko/files/pic0*.png
!.blinko/files/story.txt
dump.sql
50 changes: 21 additions & 29 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Set GitHub URL for the docker-compose file
github_url="https://raw.githubusercontent.com/blinko-space/blinko/refs/heads/main/docker-compose.prod.yml"
compose_file="docker-compose.prod.yml"

# Step 0: Prompt user to enter volume path or skip
echo -e "${YELLOW}Do you want to set a volume path for storing .blinko data? (y/n)${NC}"
read set_volume

if [ "$set_volume" = "y" ]; then
echo -e "${YELLOW}Enter the path where you want to store .blinko data:${NC}"
read volume_path
fi

# Step 1: Fetch docker-compose file using curl
echo -e "${YELLOW}1. ✅ Fetching docker-compose file from GitHub...${NC}"
curl -o $compose_file $github_url
Expand All @@ -21,37 +29,21 @@ if [ $? -ne 0 ]; then
fi
echo -e "${GREEN}Successfully downloaded docker-compose file: $compose_file${NC}"

# Default environment variables
NEXTAUTH_URL_DEFAULT="http://localhost:1111"
NEXT_PUBLIC_BASE_URL_DEFAULT="http://localhost:1111"

# Step 2: Ask user if they want to change NEXTAUTH_URL
echo -e "${YELLOW}2. ❓ Configuring NEXTAUTH_URL...${NC}"
read -p "Do you want to change NEXTAUTH_URL from the default ($NEXTAUTH_URL_DEFAULT)? [y/N]: " change_nextauth_url
if [[ "$change_nextauth_url" == "y" || "$change_nextauth_url" == "Y" ]]; then
read -p "Enter new NEXTAUTH_URL: " NEXTAUTH_URL
else
NEXTAUTH_URL=$NEXTAUTH_URL_DEFAULT
fi
# Step 2: Update docker-compose file to include the volume if set by user
if [ "$set_volume" = "y" ]; then
echo -e "${YELLOW}2. 🔄 Updating docker-compose file to include volume for .blinko...${NC}"

# Step 3: Ask user if they want to change NEXT_PUBLIC_BASE_URL
echo -e "${YELLOW}3. ❓ Configuring NEXT_PUBLIC_BASE_URL...${NC}"
read -p "Do you want to change NEXT_PUBLIC_BASE_URL from the default ($NEXT_PUBLIC_BASE_URL_DEFAULT)? [y/N]: " change_next_public_base_url
if [[ "$change_next_public_base_url" == "y" || "$change_next_public_base_url" == "Y" ]]; then
read -p "Enter new NEXT_PUBLIC_BASE_URL: " NEXT_PUBLIC_BASE_URL
else
NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL_DEFAULT
fi

# Step 4: Update the docker-compose file with the chosen environment variables
echo -e "${YELLOW}4. ✏ Updating environment variables in $compose_file...${NC}"
sed -i "s|NEXTAUTH_URL:.*|NEXTAUTH_URL: $NEXTAUTH_URL|" $compose_file
sed -i "s|NEXT_PUBLIC_BASE_URL:.*|NEXT_PUBLIC_BASE_URL: $NEXT_PUBLIC_BASE_URL|" $compose_file
# Ensure the 'volumes' section is correctly indented
awk -v path="$volume_path" '
/blinko-website:/ { print; print " volumes:"; print " - " path ":/app/.blinko"; next }
{ print }
' $compose_file > temp.yml && mv temp.yml $compose_file

echo -e "${GREEN}Environment variables updated successfully.${NC}"
echo -e "${GREEN}Volume configuration added to docker-compose file.${NC}"
fi

# Step 5: Run the docker-compose file
echo -e "${YELLOW}5. ⏳ Starting the Docker Compose setup...${NC}"
# Step 3: Run the docker-compose file
echo -e "${YELLOW}3. ⏳ Starting the Docker Compose setup...${NC}"
docker-compose -f $compose_file up -d

if [ $? -ne 0 ]; then
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"mime-types": "^2.1.35",
"mobx": "^6.13.3",
"mobx-react-lite": "^4.0.7",
"ncp": "^2.0.0",
"next": "^14.2.5",
"next-auth": "^4.24.7",
"next-themes": "^0.3.0",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

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

8 changes: 7 additions & 1 deletion prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DBBAKUP_PATH, FAISS_PATH, UPLOAD_FILE_PATH } from '../src/lib/constant'
import { PrismaClient } from '@prisma/client'

import fs from 'fs/promises'
import { ncp } from 'ncp'
const tag = [
{
"id": 1,
Expand Down Expand Up @@ -205,6 +207,10 @@ async function main() {
await prisma.$executeRaw`SELECT setval('"tagsToNote_id_seq"', (SELECT MAX(id) FROM "tagsToNote") + 1);`
await prisma.$executeRaw`SELECT setval('attachments_id_seq', (SELECT MAX(id) FROM "attachments") + 1);`
}
await Promise.all([fs.mkdir(UPLOAD_FILE_PATH), fs.mkdir(FAISS_PATH), fs.mkdir(DBBAKUP_PATH)])
ncp('prisma/seedfiles', UPLOAD_FILE_PATH,(err)=>{
console.log(err)
})
}

main()
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
6 changes: 2 additions & 4 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Set GitHub URL for the docker-compose file
github_url="https://raw.githubusercontent.com/blinko-space/blinko/refs/heads/main/docker-compose.prod.yml"
compose_file="docker-compose.prod.yml"

# Step 1: Remove existing Docker image
echo -e "${YELLOW}1. 🗑 Removing existing blinkospace/blinko Docker image...${NC}"
docker rmi blinkospace/blinko:latest -f
# echo -e "${YELLOW}1. 🗑 Removing existing blinkospace/blinko Docker image...${NC}"
# docker rmi blinkospace/blinko:latest -f

if [ $? -ne 0 ]; then
echo -e "${RED}Failed to remove Docker image. It may not exist or there may be an issue with Docker.${NC}"
Expand Down

0 comments on commit 1d8e176

Please sign in to comment.