Update Dockerfile
Browse files- Dockerfile +24 -12
Dockerfile
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
|
|
| 1 |
FROM node:20-bookworm
|
| 2 |
|
| 3 |
-
# Установка
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
curl \
|
| 6 |
gnupg \
|
| 7 |
ca-certificates \
|
| 8 |
lsb-release \
|
|
|
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
|
|
|
| 11 |
RUN curl https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
|
| 12 |
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list
|
| 13 |
RUN apt-get update && apt-get install -y cloudflare-warp
|
| 14 |
|
| 15 |
-
#
|
| 16 |
WORKDIR /app
|
| 17 |
|
| 18 |
-
#
|
| 19 |
RUN echo '{"name":"warp-express","version":"1.0.0","dependencies":{"express":"^4.18.2","axios":"^1.7.2","socks-proxy-agent":"^8.0.4"}}' > package.json
|
| 20 |
|
| 21 |
-
#
|
| 22 |
RUN npm install
|
| 23 |
|
|
|
|
| 24 |
RUN echo "const express = require('express');" > app.js \
|
| 25 |
&& echo "const axios = require('axios');" >> app.js \
|
| 26 |
&& echo "const SocksProxyAgent = require('socks-proxy-agent');" >> app.js \
|
| 27 |
&& echo "const app = express();" >> app.js \
|
| 28 |
&& echo "const port = 7860;" >> app.js \
|
|
|
|
|
|
|
| 29 |
&& echo "app.get('/', async (req, res) => {" >> app.js \
|
| 30 |
&& echo " try {" >> app.js \
|
| 31 |
-
&& echo " const agent = new SocksProxyAgent('socks5://localhost:24000');" >> app.js \
|
| 32 |
&& echo " const response = await axios.get('https://ip.oxylabs.io/location', { " >> app.js \
|
| 33 |
&& echo " httpsAgent: agent," >> app.js \
|
| 34 |
-
&& echo " proxy: false" >> app.js \
|
|
|
|
| 35 |
&& echo " });" >> app.js \
|
| 36 |
&& echo " res.type('json').send(JSON.stringify(response.data, null, 2));" >> app.js \
|
| 37 |
&& echo " } catch (error) {" >> app.js \
|
|
@@ -40,25 +46,31 @@ RUN echo "const express = require('express');" > app.js \
|
|
| 40 |
&& echo "});" >> app.js \
|
| 41 |
&& echo "app.listen(port, () => console.log('Server running on port ' + port));" >> app.js
|
| 42 |
|
| 43 |
-
# Скрипт запуска
|
| 44 |
RUN echo '#!/bin/bash' > /entrypoint.sh \
|
| 45 |
-
&& echo '
|
| 46 |
-
&& echo '
|
|
|
|
|
|
|
| 47 |
&& echo 'warp-cli registration new --accept-tos' >> /entrypoint.sh \
|
| 48 |
&& echo 'warp-cli mode proxy' >> /entrypoint.sh \
|
| 49 |
-
&& echo 'warp-cli proxy port
|
|
|
|
| 50 |
&& echo 'warp-cli connect' >> /entrypoint.sh \
|
|
|
|
| 51 |
&& echo 'while true; do' >> /entrypoint.sh \
|
|
|
|
| 52 |
&& echo ' warp-cli disconnect' >> /entrypoint.sh \
|
| 53 |
&& echo ' sleep 5' >> /entrypoint.sh \
|
| 54 |
&& echo ' warp-cli connect' >> /entrypoint.sh \
|
| 55 |
-
&& echo '
|
| 56 |
&& echo 'done &' >> /entrypoint.sh \
|
|
|
|
| 57 |
&& echo 'node app.js' >> /entrypoint.sh \
|
| 58 |
&& chmod +x /entrypoint.sh
|
| 59 |
|
| 60 |
# Открываем порт
|
| 61 |
EXPOSE 7860
|
| 62 |
|
| 63 |
-
# Запускаем
|
| 64 |
CMD ["/bin/bash", "/entrypoint.sh"]
|
|
|
|
| 1 |
+
# Используем базовый образ Node.js
|
| 2 |
FROM node:20-bookworm
|
| 3 |
|
| 4 |
+
# Установка необходимых зависимостей
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
curl \
|
| 7 |
gnupg \
|
| 8 |
ca-certificates \
|
| 9 |
lsb-release \
|
| 10 |
+
iptables \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# Установка Cloudflare WARP
|
| 14 |
RUN curl https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
|
| 15 |
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list
|
| 16 |
RUN apt-get update && apt-get install -y cloudflare-warp
|
| 17 |
|
| 18 |
+
# Создаем рабочую директорию
|
| 19 |
WORKDIR /app
|
| 20 |
|
| 21 |
+
# Генерируем package.json
|
| 22 |
RUN echo '{"name":"warp-express","version":"1.0.0","dependencies":{"express":"^4.18.2","axios":"^1.7.2","socks-proxy-agent":"^8.0.4"}}' > package.json
|
| 23 |
|
| 24 |
+
# Устанавливаем зависимости
|
| 25 |
RUN npm install
|
| 26 |
|
| 27 |
+
# Создаем файл приложения
|
| 28 |
RUN echo "const express = require('express');" > app.js \
|
| 29 |
&& echo "const axios = require('axios');" >> app.js \
|
| 30 |
&& echo "const SocksProxyAgent = require('socks-proxy-agent');" >> app.js \
|
| 31 |
&& echo "const app = express();" >> app.js \
|
| 32 |
&& echo "const port = 7860;" >> app.js \
|
| 33 |
+
&& echo "const proxyUrl = 'socks5://127.0.0.1:1080';" >> app.js \
|
| 34 |
+
&& echo "const agent = new SocksProxyAgent(proxyUrl);" >> app.js \
|
| 35 |
&& echo "app.get('/', async (req, res) => {" >> app.js \
|
| 36 |
&& echo " try {" >> app.js \
|
|
|
|
| 37 |
&& echo " const response = await axios.get('https://ip.oxylabs.io/location', { " >> app.js \
|
| 38 |
&& echo " httpsAgent: agent," >> app.js \
|
| 39 |
+
&& echo " proxy: false," >> app.js \
|
| 40 |
+
&& echo " timeout: 5000" >> app.js \
|
| 41 |
&& echo " });" >> app.js \
|
| 42 |
&& echo " res.type('json').send(JSON.stringify(response.data, null, 2));" >> app.js \
|
| 43 |
&& echo " } catch (error) {" >> app.js \
|
|
|
|
| 46 |
&& echo "});" >> app.js \
|
| 47 |
&& echo "app.listen(port, () => console.log('Server running on port ' + port));" >> app.js
|
| 48 |
|
| 49 |
+
# Скрипт запуска (в одном файле)
|
| 50 |
RUN echo '#!/bin/bash' > /entrypoint.sh \
|
| 51 |
+
&& echo '# Запуск WARP сервиса' >> /entrypoint.sh \
|
| 52 |
+
&& echo 'warp-svc &' >> /entrypoint.sh \
|
| 53 |
+
&& echo 'sleep 5' >> /entrypoint.sh \
|
| 54 |
+
&& echo '# Регистрация и настройка' >> /entrypoint.sh \
|
| 55 |
&& echo 'warp-cli registration new --accept-tos' >> /entrypoint.sh \
|
| 56 |
&& echo 'warp-cli mode proxy' >> /entrypoint.sh \
|
| 57 |
+
&& echo 'warp-cli proxy port 1080' >> /entrypoint.sh \
|
| 58 |
+
&& echo '# Первоначальное подключение' >> /entrypoint.sh \
|
| 59 |
&& echo 'warp-cli connect' >> /entrypoint.sh \
|
| 60 |
+
&& echo '# Цикл ротации IP каждые 5 минут' >> /entrypoint.sh \
|
| 61 |
&& echo 'while true; do' >> /entrypoint.sh \
|
| 62 |
+
&& echo ' sleep 300' >> /entrypoint.sh \
|
| 63 |
&& echo ' warp-cli disconnect' >> /entrypoint.sh \
|
| 64 |
&& echo ' sleep 5' >> /entrypoint.sh \
|
| 65 |
&& echo ' warp-cli connect' >> /entrypoint.sh \
|
| 66 |
+
&& echo ' echo "IP rotated at $(date)"' >> /entrypoint.sh \
|
| 67 |
&& echo 'done &' >> /entrypoint.sh \
|
| 68 |
+
&& echo '# Запуск Express сервера' >> /entrypoint.sh \
|
| 69 |
&& echo 'node app.js' >> /entrypoint.sh \
|
| 70 |
&& chmod +x /entrypoint.sh
|
| 71 |
|
| 72 |
# Открываем порт
|
| 73 |
EXPOSE 7860
|
| 74 |
|
| 75 |
+
# Запускаем скрипт
|
| 76 |
CMD ["/bin/bash", "/entrypoint.sh"]
|