torrust-tracker

wip

tt


ее
This commit is contained in:
STAM 2023-04-05 17:50:45 +03:00
parent 8ae9fb0838
commit cf2771688d
Signed by: stam
GPG Key ID: 4F57E51F9C45F8CD
11 changed files with 209 additions and 18 deletions

View File

@ -126,6 +126,9 @@ jobs:
- name: Build and Deploy Torrust Tracker
run: cd linux/ecosystem/torrust-tracker && make build && make deploy
- name: Build and Deploy Torrust Index
run: cd linux/ecosystem/torrust-index && make build && make deploy
##################################################################################
build-monero-cli-image:

View File

@ -1,5 +1,8 @@
# Changelog
## 2023
* `apr`
* `apache2` image fixed
* added `torrust-index` image
* `feb-mar`
* added new `sentry` advanced image
* `jan`

View File

@ -402,6 +402,7 @@ ecosystem-opentracker-images:
ecosystem-torrust-tracker-images:
cd `pwd`/linux/ecosystem/torrust-tracker && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/torrust-index && pwd && make build && make deploy
ecosystem-monero-images:
cd `pwd`/linux/ecosystem/monero/monerod && pwd && make build && make deploy

View File

@ -0,0 +1,77 @@
FROM epicmorg/nodejs:node19 as nodejs
RUN git clone https://github.com/torrust/torrust-index-frontend.git -b develop /opt/torrust-index-frontend && \
cd /opt/torrust-index-frontend && \
echo "VITE_API_BASE_URL=/api" > .env && \
npm i && \
npm run build && \
ls -las && \
cd ./dist/ && \
ls -las
FROM epicmorg/debian:bullseye-develop as builder
RUN git clone https://github.com/torrust/torrust-index-backend.git -b develop /opt/torrust-index-backend && \
cd /opt/torrust-index-backend && \
echo "DATABASE_URL=sqlite://data.db?mode=rwc" >> .env && \
cargo install sqlx-cli && \
sqlx db setup && \
cargo build --release && \
ls -las && \
cd ./target/release/ && \
mv ./main ./torrust-index-backend && \
mv ./upgrade ./torrust-index-upgrade && \
ls -las
FROM epicmorg/nginx:latest
ENV TORRUST_PORT=80
ENV TORRUST_DIR=/app
ENV TORRUST_BIN=${TORRUST_DIR}/bin
ENV TORRUST_DATA=${TORRUST_DIR}/data
ENV TORRUST_UPLOADS=${TORRUST_DIR}/uploads
ENV TORRUST_WWW=${TORRUST_DIR}/www
RUN mkdir -p ${TORRUST_DIR} ${TORRUST_BIN} ${TORRUST_DATA} ${TORRUST_UPLOADS} ${TORRUST_WWW}
RUN ln -sf ${TORRUST_DATA}/config.toml ${TORRUST_BIN}/config.toml
RUN ln -sf ${TORRUST_DATA}/data.db ${TORRUST_BIN}/data.db
COPY --from=builder /opt/torrust-index-backend/target/release/torrust-index-backend ${TORRUST_BIN}/torrust-index-backend
COPY --from=builder /opt/torrust-index-backend/target/release/torrust-index-upgrade ${TORRUST_BIN}/torrust-index-upgrade
RUN chmod +x ${TORRUST_BIN}/torrust-index-backend && \
chmod +x ${TORRUST_BIN}/torrust-index-upgrade
COPY --from=nodejs /opt/torrust-index-frontend/dist/ ${TORRUST_WWW}
RUN tree ${TORRUST_WWW} && \
chown -R www-data:www-data ${TORRUST_WWW} && \
ls -las ${TORRUST_WWW}
RUN apt-get update && \
apt-get -y install supervisor && \
mkdir -p /var/log/supervisor && \
mkdir -p /etc/supervisor/conf.d
EXPOSE ${TORRUST_PORT}
EXPOSE ${TORRUST_PORT}/udp
WORKDIR ${TORRUST_DIR}
VOLUME ${TORRUST_DATA}
VOLUME ${TORRUST_UPLOADS}
# nginx base configuration
ADD torrust-index.conf /etc/nginx/sites-enabled/torrust-index.conf
# supervisor base configuration
ADD supervisor.conf /etc/supervisor.conf
# Add image configuration and scripts
COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
RUN chmod 755 /usr/bin/docker-entrypoint.sh
ENTRYPOINT ["tini", "-s", "--", "docker-entrypoint.sh"]
CMD ["docker-entrypoint.sh"]

View File

@ -0,0 +1,19 @@
all: app
app:
make build
make deploy
make clean
build:
docker-compose build --compress --parallel --progress plain
deploy:
docker-compose push
clean:
docker container prune -f
docker image prune -f
docker network prune -f
docker volume prune -f
docker system prune -af

View File

@ -0,0 +1,6 @@
version: '3.9'
services:
app:
image: "epicmorg/torrust-index:latest"
build:
context: .

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
# Setup default Opts
: ${TORRUST_PORT:=80}
echo "[torrust-index] Starting up with supervisord"
supervisord -c /etc/supervisor.conf

View File

@ -0,0 +1,14 @@
[supervisord]
nodaemon=true
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
killasgroup=true
stopasgroup=true
redirect_stderr=true
[program:torrust-index-backend]
directory=/app/bin
command=/bin/bash -c "/app/bin/torrust-index-backend"
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log

View File

@ -0,0 +1,60 @@
set_real_ip_from 192.168.0.0/16;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 100.64.0.0/10;
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
map $scheme $msiis {
http off;
https on;
}
server {
listen 80;
server_name _;
root /app/www/;
location / {
try_files $uri $uri/ /index.html;
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
location /api/ {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
proxy_set_header 'Access-Control-Allow-Origin' '*';
proxy_set_header 'Access-Control-Allow-Credentials' 'true';
proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
proxy_set_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-FORWARDED-PROTOCOL $scheme;
proxy_set_header X-Url-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Front-End-Https $msiis;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 512;
proxy_buffering off;
port_in_redirect off;
proxy_set_header Upgrade $http_upgrade; # WebSocket support
proxy_set_header Connection $connection_upgrade; # WebSocket support
proxy_pass http://127.0.0.1:3000/;
}
}

View File

@ -1,7 +1,7 @@
FROM epicmorg/debian:bullseye-develop as builder
RUN git clone https://github.com/torrust/torrust-tracker.git /opt/torrust-tracker && \
RUN git clone https://github.com/torrust/torrust-tracker.git -b develop /opt/torrust-tracker && \
cd /opt/torrust-tracker && \
cargo build --release && \
ls -las && \
@ -11,25 +11,25 @@ RUN git clone https://github.com/torrust/torrust-tracker.git /opt/torrust-tracke
FROM epicmorg/debian:bullseye
ENV TRACKER_PORT=1337
ENV TRACKER_ADMIN=1488
ENV TRACKER_DIR=/app
ENV TRACKER_DATA=${TRACKER_DIR}/data
ARG TORRUST_PORT=1337
ARG TORRUST_ADMIN=1488
ENV TORRUST_DIR=/app
ENV TORRUST_DATA=${TORRUST_DIR}/data
RUN mkdir -p ${TRACKER_DIR} ${TRACKER_DATA}
RUN mkdir -p ${TORRUST_DIR} ${TORRUST_DATA}
RUN ln -sf ${TRACKER_DATA}/config.toml ${TRACKER_DIR}/config.toml
RUN ln -sf ${TRACKER_DATA}/data.db ${TRACKER_DIR}/data.db
RUN ln -sf ${TORRUST_DATA}/config.toml ${TORRUST_DIR}/config.toml
RUN ln -sf ${TORRUST_DATA}/data.db ${TORRUST_DIR}/data.db
COPY --from=builder /opt/torrust-tracker/target/release/torrust-tracker ${TRACKER_DIR}/torrust-tracker
RUN chmod 755 ${TRACKER_DIR}/torrust-tracker
COPY --from=builder /opt/torrust-tracker/target/release/torrust-tracker ${TORRUST_DIR}/torrust-tracker
RUN chmod 755 ${TORRUST_DIR}/torrust-tracker
EXPOSE ${TRACKER_PORT}
EXPOSE ${TRACKER_PORT}/udp
EXPOSE ${TRACKER_ADMIN}
EXPOSE ${TORRUST_PORT}
EXPOSE ${TORRUST_PORT}/udp
EXPOSE ${TORRUST_ADMIN}
WORKDIR ${TRACKER_DIR}
VOLUME ${TRACKER_DATA}
WORKDIR ${TORRUST_DIR}
VOLUME ${TORRUST_DATA}
# Add image configuration and scripts
COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh

View File

@ -2,8 +2,8 @@
set -euo pipefail
# Setup default Opts
: ${RACKER_PORT:=1337}
: ${RACKER_ADMIN:=1488}
: ${TORRUST_PORT:=1337}
: ${TORRUST_ADMIN:=1488}
echo "[torrust-tracker] Starting up"
cd /app