Compare commits
2 Commits
4e04063469
...
d0a0abed68
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0a0abed68 | ||
|
|
4a97057825 |
@@ -1,4 +1,17 @@
|
||||
services:
|
||||
# Warp Socks Proxy Service (Internal only - no external ports exposed)
|
||||
warp-proxy:
|
||||
image: ghcr.io/mon-ius/docker-warp-socks:v5
|
||||
container_name: dsas-cca-warp-proxy
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- cca_network
|
||||
# Only expose port internally, not to host
|
||||
expose:
|
||||
- "9091"
|
||||
profiles:
|
||||
- proxy
|
||||
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
@@ -11,16 +24,24 @@ services:
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
# Proxy configuration (only active when USE_PROXY=true)
|
||||
- USE_PROXY=${USE_PROXY:-false}
|
||||
- HTTP_PROXY=${HTTP_PROXY:-}
|
||||
- HTTPS_PROXY=${HTTPS_PROXY:-}
|
||||
- ALL_PROXY=${ALL_PROXY:-}
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
warp-proxy:
|
||||
condition: service_started
|
||||
required: false
|
||||
volumes:
|
||||
- ./services/cookies.json:/usr/src/app/services/cookies.json
|
||||
networks:
|
||||
- cca_network
|
||||
mem_limit: 1g
|
||||
cpus: 1.0
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
redis:
|
||||
image: "redis:8.0-alpine"
|
||||
@@ -36,7 +57,6 @@ services:
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
mem_limit: 256m
|
||||
|
||||
volumes:
|
||||
redis_data:
|
||||
|
||||
12
example.env
12
example.env
@@ -17,3 +17,15 @@ CONCURRENT_API_CALLS=16
|
||||
STAFF_UPDATE_INTERVAL_MINS=360
|
||||
CLUB_UPDATE_INTERVAL_MINS=360
|
||||
LOG_LEVEL=info # Example: 'debug', 'info', 'warn', 'error'
|
||||
|
||||
# Proxy Configuration (Optional)
|
||||
# Set USE_PROXY=true to enable proxy for Playwright requests
|
||||
USE_PROXY=false
|
||||
# Custom proxy server (default: socks5://warp-proxy:9091 when using warp-proxy service)
|
||||
# Examples:
|
||||
# HTTP: http://proxy.example.com:8080
|
||||
# SOCKS5: socks5://proxy.example.com:1080
|
||||
# Warp: socks5://warp-proxy:9091
|
||||
ALL_PROXY=
|
||||
HTTP_PROXY=
|
||||
HTTPS_PROXY=
|
||||
|
||||
@@ -8,16 +8,31 @@ const COOKIE_FILE_PATH = resolve(import.meta.dir, 'cookies.json');
|
||||
|
||||
let _inMemoryCookies: Cookie[] | null = null;
|
||||
|
||||
// Proxy configuration
|
||||
const USE_PROXY = process.env.USE_PROXY === 'true';
|
||||
const PROXY_SERVER = process.env.ALL_PROXY || process.env.HTTP_PROXY || `socks5://warp-proxy:9091`;
|
||||
|
||||
/**
|
||||
* Login using Playwright and extract cookies
|
||||
*/
|
||||
export async function loginWithPlaywright(username: string, password: string): Promise<Cookie[]> {
|
||||
logger.info('Starting Playwright login process...');
|
||||
|
||||
const browser = await chromium.launch({
|
||||
const browserLaunchOptions: any = {
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
});
|
||||
};
|
||||
|
||||
// Configure proxy if enabled
|
||||
if (USE_PROXY) {
|
||||
logger.info(`Using proxy: ${PROXY_SERVER}`);
|
||||
browserLaunchOptions.proxy = {
|
||||
server: PROXY_SERVER,
|
||||
bypass: 'localhost,127.0.0.1,::1'
|
||||
};
|
||||
}
|
||||
|
||||
const browser = await chromium.launch(browserLaunchOptions);
|
||||
|
||||
try {
|
||||
const context = await browser.newContext({
|
||||
|
||||
Reference in New Issue
Block a user