init commit
This commit is contained in:
128
setup.sh
Executable file
128
setup.sh
Executable file
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Запустите этот скрипт из корня вашего репозитория (~/links)
|
||||
|
||||
# Переменные
|
||||
BACKEND_DIR="backend"
|
||||
FRONTEND_DIR="frontend"
|
||||
APPS=("users" "links" "customization")
|
||||
|
||||
# 1. Создаем .gitignore и README
|
||||
cat > .gitignore << 'EOF'
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.env
|
||||
media/
|
||||
node_modules/
|
||||
dist/
|
||||
.venv/
|
||||
EOF
|
||||
|
||||
if [ ! -f README.md ]; then
|
||||
echo "# Клон Linktr.ee на Django" > README.md
|
||||
fi
|
||||
|
||||
echo "Настраиваем backend-проект"
|
||||
# 2. Создаем backend-проект
|
||||
mkdir -p $BACKEND_DIR && cd $BACKEND_DIR
|
||||
|
||||
# Виртуальное окружение
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
|
||||
# Устанавливаем зависимости
|
||||
pip install Django psycopg2-binary djangorestframework pillow django-tailwind whitenoise gunicorn
|
||||
|
||||
# Инициализируем Django-проект (если не создан)
|
||||
if [ ! -f config/manage.py ]; then
|
||||
django-admin startproject config .
|
||||
fi
|
||||
|
||||
# Создаем приложения, если их нет
|
||||
for app in "${APPS[@]}"; do
|
||||
if [ ! -d "$app" ]; then
|
||||
python manage.py startapp $app
|
||||
fi
|
||||
done
|
||||
|
||||
# Генерируем requirements.txt
|
||||
pip freeze > requirements.txt
|
||||
|
||||
deactivate
|
||||
cd ..
|
||||
|
||||
# 3. Dockerfile для backend
|
||||
cat > $BACKEND_DIR/Dockerfile << 'EOF'
|
||||
FROM python:3.10-slim
|
||||
WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY . .
|
||||
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000"]
|
||||
EOF
|
||||
|
||||
echo "Создаем docker-compose.yml"
|
||||
# 4. docker-compose.yml в корне
|
||||
cat > docker-compose.yml << 'EOF'
|
||||
version: '3.8'
|
||||
services:
|
||||
web:
|
||||
build: ./backend
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
- media_volume:/app/media
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "8000:8000"
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
image: postgres:14
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data/
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
postgres_data:
|
||||
media_volume:
|
||||
EOF
|
||||
|
||||
echo "Настраиваем frontend-проект"
|
||||
# 5. Frontend: инициализация
|
||||
mkdir -p $FRONTEND_DIR && cd $FRONTEND_DIR
|
||||
|
||||
if [ ! -f package.json ]; then
|
||||
npm init -y
|
||||
npm install axios react react-dom
|
||||
fi
|
||||
mkdir -p public src/components src/pages src/services src/styles
|
||||
|
||||
# public/index.html
|
||||
cat > public/index.html << 'EOF'
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Linktr Clone</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="../src/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
# src/index.js
|
||||
cat > src/index.js << 'EOF'
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
ReactDOM.render(<h1>Linktr Clone</h1>, document.getElementById('root'));
|
||||
EOF
|
||||
|
||||
cd ..
|
||||
|
||||
echo "Проект настроен успешно!"
|
||||
Reference in New Issue
Block a user