deploy
This commit is contained in:
parent
4f188810a8
commit
0c9247f276
16 changed files with 55 additions and 24 deletions
|
|
@ -1,5 +1,36 @@
|
||||||
# Progress Log
|
# Progress Log
|
||||||
|
|
||||||
|
## 2025-11-16 (Evening) - Let's Encrypt SSL Certificate Setup ✅ COMPLETED
|
||||||
|
|
||||||
|
**Feature:** SSL Certificate Configuration for API Domain (api.memo-cards.online)
|
||||||
|
|
||||||
|
**Completed Tasks:**
|
||||||
|
- ✅ Configured nginx with ACME challenge support for Let's Encrypt
|
||||||
|
- ✅ Fixed backend-build_app_webroot.sh script port configuration (8443 → 8081)
|
||||||
|
- ✅ Created proper directory structure for ACME challenges (/var/www/html/.well-known/acme-challenge/)
|
||||||
|
- ✅ Set up automatic SSL certificate renewal via cron job
|
||||||
|
- ✅ Tested certificate obtaining process with webroot method
|
||||||
|
- ✅ Updated systemd service configuration for dual HTTP/HTTPS mode
|
||||||
|
|
||||||
|
**Technical Implementation:**
|
||||||
|
- **Nginx Configuration:** Server block with ACME challenge location and proxy to backend
|
||||||
|
- **SSL Setup:** Let's Encrypt certificate with webroot challenge method
|
||||||
|
- **Security:** Proper file permissions and directory ownership (www-data)
|
||||||
|
- **Automation:** Cron job for daily certificate renewal with nginx reload
|
||||||
|
|
||||||
|
**Configuration Details:**
|
||||||
|
- **Domain:** api.memo-cards.online
|
||||||
|
- **Backend Port:** 8081 (corrected from 8443)
|
||||||
|
- **Webroot Path:** /var/www/html/.well-known/acme-challenge/
|
||||||
|
- **Certificate Path:** /etc/letsencrypt/live/api.memo-cards.online/
|
||||||
|
|
||||||
|
**Scripts Updated:**
|
||||||
|
- `backend-build_app_webroot.sh` - Fixed port configuration and webroot setup
|
||||||
|
|
||||||
|
**Next Action:** Verify HTTPS functionality and test API endpoints
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 2025-11-16 (Evening) - Forgejo Domain Setup ✅ COMPLETED
|
## 2025-11-16 (Evening) - Forgejo Domain Setup ✅ COMPLETED
|
||||||
|
|
||||||
**Feature:** Domain Configuration for Forgejo (code.mnemo-cards.online)
|
**Feature:** Domain Configuration for Forgejo (code.mnemo-cards.online)
|
||||||
|
|
@ -540,7 +571,7 @@
|
||||||
- Mounted the v2 pipeline at `/api/v2` inside `MnemoShelf`, fixing 404 responses for public routes like `GET /api/v2/packs` on the deployed instance.
|
- Mounted the v2 pipeline at `/api/v2` inside `MnemoShelf`, fixing 404 responses for public routes like `GET /api/v2/packs` on the deployed instance.
|
||||||
|
|
||||||
## 2025-11-09 (Afternoon) - Telegram Bot Backend URL Override ✅
|
## 2025-11-09 (Afternoon) - Telegram Bot Backend URL Override ✅
|
||||||
- ✅ Introduced `BotConfig` helper with CLI option `--backend-url` and env fallback (`MNEMO_BACKEND_URL`/`BACKEND_URL`) so the Telegram bot can target HTTPS production APIs instead of hardcoded `http://localhost:8080`.
|
- ✅ Introduced `BotConfig` helper with CLI option `--backend-url` and env fallback (`MNEMO_BACKEND_URL`/`BACKEND_URL`) so the Telegram bot can target HTTPS production APIs instead of hardcoded `http://localhost:8443`.
|
||||||
- ✅ Logged selected backend endpoint during bot startup for easier diagnostics.
|
- ✅ Logged selected backend endpoint during bot startup for easier diagnostics.
|
||||||
- ✅ Added dedicated unit tests (`test/bot_config_test.dart`) covering CLI > env > default resolution order and ran `dart test` for the bot package.
|
- ✅ Added dedicated unit tests (`test/bot_config_test.dart`) covering CLI > env > default resolution order and ran `dart test` for the bot package.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@
|
||||||
|
|
||||||
## Medium Priority
|
## Medium Priority
|
||||||
- [ ] Review existing codebase architecture
|
- [ ] Review existing codebase architecture
|
||||||
- [ ] Check SSL certificate validity
|
- [x] **COMPLETED** - Set up Let's Encrypt SSL certificates for api.memo-cards.online with automatic renewal
|
||||||
|
- [ ] Verify HTTPS functionality and test API endpoints over SSL
|
||||||
- [ ] Verify database operations
|
- [ ] Verify database operations
|
||||||
- [x] Review API endpoints and documentation (v1 removal & v2 surface audit)
|
- [x] Review API endpoints and documentation (v1 removal & v2 surface audit)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class MnemoShelf {
|
||||||
final portArg =
|
final portArg =
|
||||||
args.indexOf('-p') == -1 ? null : args[args.indexOf('-p') + 1];
|
args.indexOf('-p') == -1 ? null : args[args.indexOf('-p') + 1];
|
||||||
final address = addressArg ?? InternetAddress.anyIPv4.address;
|
final address = addressArg ?? InternetAddress.anyIPv4.address;
|
||||||
final port = int.tryParse(portArg ?? '') ?? 8080;
|
final port = int.tryParse(portArg ?? '') ?? 8443;
|
||||||
final certs = args.contains('--certs')
|
final certs = args.contains('--certs')
|
||||||
? args[args.indexOf('--certs') + 1]
|
? args[args.indexOf('--certs') + 1]
|
||||||
: null; // null = HTTP without SSL
|
: null; // null = HTTP without SSL
|
||||||
|
|
@ -83,7 +83,7 @@ class MnemoShelf {
|
||||||
// 'https://1592725-cf88967.twc1.net',
|
// 'https://1592725-cf88967.twc1.net',
|
||||||
// 'https://1592725-cf88967.twc1.net:443',
|
// 'https://1592725-cf88967.twc1.net:443',
|
||||||
// '5492281-cf88967.twc1.net',
|
// '5492281-cf88967.twc1.net',
|
||||||
// '5492281-cf88967.twc1.net:8080'
|
// '5492281-cf88967.twc1.net:8443'
|
||||||
// 'http://localhost:*',
|
// 'http://localhost:*',
|
||||||
// 'http://localhost:51717', // для разработки
|
// 'http://localhost:51717', // для разработки
|
||||||
// 'http://localhost:3000', // для разработки
|
// 'http://localhost:3000', // для разработки
|
||||||
|
|
@ -189,7 +189,7 @@ class MnemoShelf {
|
||||||
shared: true,
|
shared: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// HTTPS сервер на порту + 1 (например, 8080 -> 8081)
|
// HTTPS сервер на порту + 1 (например, 8443 -> 8081)
|
||||||
final httpsPort = port + 1;
|
final httpsPort = port + 1;
|
||||||
final httpsServer = await _createServer(
|
final httpsServer = await _createServer(
|
||||||
handler,
|
handler,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ info:
|
||||||
title: Api
|
title: Api
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
servers:
|
servers:
|
||||||
- url: "http://localhost:8080"
|
- url: "http://localhost:8443"
|
||||||
paths:
|
paths:
|
||||||
/promocodes/<code>/apply:
|
/promocodes/<code>/apply:
|
||||||
post:
|
post:
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ echo "3️⃣ Testing: OPTIONS /packs/previews (CORS preflight)"
|
||||||
echo "--------------------------------"
|
echo "--------------------------------"
|
||||||
curl -s -w "\nHTTP Status: %{http_code}\n" \
|
curl -s -w "\nHTTP Status: %{http_code}\n" \
|
||||||
-X OPTIONS \
|
-X OPTIONS \
|
||||||
-H "Origin: http://localhost:8080" \
|
-H "Origin: http://localhost:8443" \
|
||||||
-H "Access-Control-Request-Method: GET" \
|
-H "Access-Control-Request-Method: GET" \
|
||||||
-H "Access-Control-Request-Headers: Content-Type,app_version" \
|
-H "Access-Control-Request-Headers: Content-Type,app_version" \
|
||||||
-v \
|
-v \
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ class ShareRequestModel {
|
||||||
BOT_SHARE_DAILY_LIMIT=1
|
BOT_SHARE_DAILY_LIMIT=1
|
||||||
|
|
||||||
# Путь к бэкенду для получения referral кода (опционально)
|
# Путь к бэкенду для получения referral кода (опционально)
|
||||||
BACKEND_URL=http://localhost:8080
|
BACKEND_URL=http://localhost:8443
|
||||||
```
|
```
|
||||||
|
|
||||||
## Возможные улучшения (Future)
|
## Возможные улучшения (Future)
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ Card File → Decode PNG → Create Canvas → Add Border
|
||||||
export BOT_SHARE_DAILY_LIMIT=2
|
export BOT_SHARE_DAILY_LIMIT=2
|
||||||
|
|
||||||
# Backend URL (already in BotConfig)
|
# Backend URL (already in BotConfig)
|
||||||
export MNEMO_BACKEND_URL=http://localhost:8080
|
export MNEMO_BACKEND_URL=http://localhost:8443
|
||||||
```
|
```
|
||||||
|
|
||||||
### Image Customization
|
### Image Customization
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ dart test test/image_generator_test.dart
|
||||||
export BOT_SHARE_DAILY_LIMIT=1
|
export BOT_SHARE_DAILY_LIMIT=1
|
||||||
|
|
||||||
# Or set in command line when starting bot:
|
# Or set in command line when starting bot:
|
||||||
dart run bin/main.dart --backend-url http://localhost:8080
|
dart run bin/main.dart --backend-url http://localhost:8443
|
||||||
```
|
```
|
||||||
|
|
||||||
### Image Customization:
|
### Image Customization:
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class DBManager {
|
||||||
// Backend API URL for generating auth codes
|
// Backend API URL for generating auth codes
|
||||||
final String backendUrl;
|
final String backendUrl;
|
||||||
|
|
||||||
DBManager(this.notify, {this.backendUrl = 'http://localhost:8080'});
|
DBManager(this.notify, {this.backendUrl = 'http://localhost:8443'});
|
||||||
|
|
||||||
Future<void> init(ArgResults results) async {
|
Future<void> init(ArgResults results) async {
|
||||||
final dir = results.option('isar') ?? '../mnemo_cards_backend/isar/';
|
final dir = results.option('isar') ?? '../mnemo_cards_backend/isar/';
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class BotConfig {
|
||||||
final String backendUrl;
|
final String backendUrl;
|
||||||
final int shareDailyLimit;
|
final int shareDailyLimit;
|
||||||
|
|
||||||
static const String defaultBackendUrl = 'http://localhost:8080';
|
static const String defaultBackendUrl = 'http://localhost:8443';
|
||||||
static const int defaultShareDailyLimit = 1;
|
static const int defaultShareDailyLimit = 1;
|
||||||
|
|
||||||
factory BotConfig.fromArgs(
|
factory BotConfig.fromArgs(
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ rm server_build.exe
|
||||||
if [ -d "/etc/letsencrypt/live/api.memo-cards.online" ] && [ -f "/etc/letsencrypt/live/api.memo-cards.online/fullchain.pem" ]; then
|
if [ -d "/etc/letsencrypt/live/api.memo-cards.online" ] && [ -f "/etc/letsencrypt/live/api.memo-cards.online/fullchain.pem" ]; then
|
||||||
echo "✅ Let's Encrypt сертификаты найдены. Запускаем в двойном режиме (HTTP + HTTPS)"
|
echo "✅ Let's Encrypt сертификаты найдены. Запускаем в двойном режиме (HTTP + HTTPS)"
|
||||||
# Обновляем systemd сервис для двойного режима
|
# Обновляем systemd сервис для двойного режима
|
||||||
sudo sed -i 's|ExecStart=$BACKEND_DIR/server.exe.*|ExecStart=$BACKEND_DIR/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8080|' /etc/systemd/system/mnemo_cards_server.service
|
sudo sed -i 's|ExecStart=$BACKEND_DIR/server.exe.*|ExecStart=$BACKEND_DIR/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8443|' /etc/systemd/system/mnemo_cards_server.service
|
||||||
else
|
else
|
||||||
echo "⚠️ Let's Encrypt сертификаты не найдены или повреждены. Пытаемся создать..."
|
echo "⚠️ Let's Encrypt сертификаты не найдены или повреждены. Пытаемся создать..."
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ else
|
||||||
echo "✅ Let's Encrypt сертификат успешно создан!"
|
echo "✅ Let's Encrypt сертификат успешно создан!"
|
||||||
echo "🚀 Запускаем в двойном режиме (HTTP + HTTPS)"
|
echo "🚀 Запускаем в двойном режиме (HTTP + HTTPS)"
|
||||||
# Обновляем systemd сервис для двойного режима
|
# Обновляем systemd сервис для двойного режима
|
||||||
sudo sed -i 's|ExecStart=$BACKEND_DIR/server.exe.*|ExecStart=$BACKEND_DIR/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8080|' /etc/systemd/system/mnemo_cards_server.service
|
sudo sed -i 's|ExecStart=$BACKEND_DIR/server.exe.*|ExecStart=$BACKEND_DIR/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8443|' /etc/systemd/system/mnemo_cards_server.service
|
||||||
else
|
else
|
||||||
echo "❌ Не удалось создать Let's Encrypt сертификат. Запускаем в HTTP режиме"
|
echo "❌ Не удалось создать Let's Encrypt сертификат. Запускаем в HTTP режиме"
|
||||||
echo "💡 Возможные причины и решения:"
|
echo "💡 Возможные причины и решения:"
|
||||||
|
|
@ -73,7 +73,7 @@ else
|
||||||
echo " - Сертификат уже был получен ранее - проверьте /etc/letsencrypt/live/"
|
echo " - Сертификат уже был получен ранее - проверьте /etc/letsencrypt/live/"
|
||||||
echo " - Используйте webroot режим если есть веб-сервер: certbot certonly --webroot -w /var/www/html -d api.memo-cards.online"
|
echo " - Используйте webroot режим если есть веб-сервер: certbot certonly --webroot -w /var/www/html -d api.memo-cards.online"
|
||||||
# Возвращаем обычный режим
|
# Возвращаем обычный режим
|
||||||
sudo sed -i 's|ExecStart=$BACKEND_DIR/server.exe.*|ExecStart=$BACKEND_DIR/server.exe -a 0.0.0.0 -p 8080|' /etc/systemd/system/mnemo_cards_server.service
|
sudo sed -i 's|ExecStart=$BACKEND_DIR/server.exe.*|ExecStart=$BACKEND_DIR/server.exe -a 0.0.0.0 -p 8443|' /etc/systemd/system/mnemo_cards_server.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Возвращаем веб-сервера в исходное состояние
|
# Возвращаем веб-сервера в исходное состояние
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ rm server_build.exe
|
||||||
if [ -d "/etc/letsencrypt/live/api.memo-cards.online" ] && [ -f "/etc/letsencrypt/live/api.memo-cards.online/fullchain.pem" ]; then
|
if [ -d "/etc/letsencrypt/live/api.memo-cards.online" ] && [ -f "/etc/letsencrypt/live/api.memo-cards.online/fullchain.pem" ]; then
|
||||||
echo "✅ Let's Encrypt сертификаты найдены. Запускаем в двойном режиме (HTTP + HTTPS)"
|
echo "✅ Let's Encrypt сертификаты найдены. Запускаем в двойном режиме (HTTP + HTTPS)"
|
||||||
# Обновляем systemd сервис для двойного режима
|
# Обновляем systemd сервис для двойного режима
|
||||||
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8080|' /etc/systemd/system/mnemo_cards_server.service
|
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8081|' /etc/systemd/system/mnemo_cards_server.service
|
||||||
else
|
else
|
||||||
echo "⚠️ Let's Encrypt сертификаты не найдены. Пытаемся создать с помощью webroot режима..."
|
echo "⚠️ Let's Encrypt сертификаты не найдены. Пытаемся создать с помощью webroot режима..."
|
||||||
|
|
||||||
|
|
@ -37,17 +37,16 @@ else
|
||||||
echo "✅ Let's Encrypt сертификат успешно создан через webroot!"
|
echo "✅ Let's Encrypt сертификат успешно создан через webroot!"
|
||||||
echo "🚀 Запускаем в двойном режиме (HTTP + HTTPS)"
|
echo "🚀 Запускаем в двойном режиме (HTTP + HTTPS)"
|
||||||
# Обновляем systemd сервис для двойного режима
|
# Обновляем systemd сервис для двойного режима
|
||||||
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8080|' /etc/systemd/system/mnemo_cards_server.service
|
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8081|' /etc/systemd/system/mnemo_cards_server.service
|
||||||
else
|
else
|
||||||
echo "❌ Не удалось создать Let's Encrypt сертификат через webroot. Запускаем в HTTP режиме"
|
echo "❌ Не удалось создать Let's Encrypt сертификат через webroot"
|
||||||
echo "💡 Убедитесь, что:"
|
echo "💡 Убедитесь, что:"
|
||||||
echo " - У вас установлен и запущен веб-сервер (nginx/apache)"
|
echo " - У вас установлен и запущен веб-сервер (nginx/apache)"
|
||||||
echo " - Домен api.memo-cards.online указывает на этот сервер"
|
echo " - Домен api.memo-cards.online указывает на этот сервер"
|
||||||
echo " - Директория /var/www/html доступна для записи certbot"
|
echo " - Директория /var/www/html доступна для записи certbot"
|
||||||
echo " - Firewall разрешает входящие соединения на порт 80"
|
echo " - Firewall разрешает входящие соединения на порт 80"
|
||||||
echo " - Веб-сервер правильно настроен для обслуживания .well-known/acme-challenge/"
|
echo " - Веб-сервер правильно настроен для обслуживания .well-known/acme-challenge/"
|
||||||
# Возвращаем обычный режим
|
exit 1
|
||||||
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe -a 0.0.0.0 -p 8080|' /etc/systemd/system/mnemo_cards_server.service
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export DOMAIN="your-domain.com"
|
||||||
|
|
||||||
**Смена API URL:**
|
**Смена API URL:**
|
||||||
```bash
|
```bash
|
||||||
export API_BASE_URL="https://your-api-server.com:8080"
|
export API_BASE_URL="https://your-api-server.com:8443"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🔧 Функции конфигурации
|
## 🔧 Функции конфигурации
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export NGINX_ENABLED="/etc/nginx/sites-enabled/$APP_NAME"
|
||||||
# API endpoints
|
# API endpoints
|
||||||
export API_BASE_URL="https://api.memo-cards.online:8081"
|
export API_BASE_URL="https://api.memo-cards.online:8081"
|
||||||
#export API_BASE_URL_DEV="http://localhost:8000"
|
#export API_BASE_URL_DEV="http://localhost:8000"
|
||||||
export API_BASE_URL_DEV="https://api.memo-cards.online:8080"
|
export API_BASE_URL_DEV="https://api.memo-cards.online:8443"
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# SSL CONFIGURATION
|
# SSL CONFIGURATION
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,7 @@ nslookup code.memo-cards.online
|
||||||
# Проверка доступности портов
|
# Проверка доступности портов
|
||||||
telnet 147.45.152.129 80
|
telnet 147.45.152.129 80
|
||||||
telnet 147.45.152.129 443
|
telnet 147.45.152.129 443
|
||||||
telnet 147.45.152.129 8080
|
telnet 147.45.152.129 8443
|
||||||
telnet 147.45.152.129 8081
|
telnet 147.45.152.129 8081
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ done
|
||||||
|
|
||||||
# Check 5: Network connectivity
|
# Check 5: Network connectivity
|
||||||
echo "5. Checking network connectivity..."
|
echo "5. Checking network connectivity..."
|
||||||
for port in 22 80 443 8080 8081; do
|
for port in 22 80 443 8443 8081; do
|
||||||
if nc -z -w5 $SERVER_IP $port 2>/dev/null; then
|
if nc -z -w5 $SERVER_IP $port 2>/dev/null; then
|
||||||
print_status "Port $port is accessible"
|
print_status "Port $port is accessible"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue