Skip to content

Commit

Permalink
ATOR-380 - Onion perf nginx (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
yumirkov authored Aug 7, 2024
1 parent 32afe12 commit b3b264e
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 55 deletions.
4 changes: 1 addition & 3 deletions .github/actions/build-and-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ runs:
context: .
file: ./Dockerfile
push: true
tags: ${{ inputs.docker-username }}/onionperf-anon:${{ github.sha }},${{ inputs.docker-username }}/onionperf-anon:${{ inputs.docker-tag }}
build-args: |
ANON_ENV=${{ inputs.environment }}
tags: ${{ inputs.docker-username }}/onionperf-anon:${{ github.sha }},${{ inputs.docker-username }}/onionperf-anon:${{ inputs.docker-tag }}
14 changes: 7 additions & 7 deletions .github/workflows/live.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
docker-password: ${{ secrets.DOCKER_HUB_PASSWORD }}
docker-tag: latest-live
environment: live
# - name: Deploy
# uses: ./.github/actions/deploy
# with:
# environment: dev
# nomad-cacert: operations/admin-ui-ca.crt
# nomad-token: ${{ secrets.NOMAD_TOKEN_SBWS_DEPLOY }} #add deploy token
# nomad-addr: ${{ secrets.NOMAD_DEPLOY_ADDR }}
- name: Deploy
uses: ./.github/actions/deploy
with:
environment: live
nomad-cacert: operations/admin-ui-ca.crt
nomad-token: ${{ secrets.NOMAD_TOKEN_ONIONPERF_DEPLOY }}
nomad-addr: ${{ secrets.NOMAD_ADDR }}
41 changes: 12 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ FROM debian:bookworm

ARG DEBIAN_FRONTEND=noninteractive

ARG ANON_ENV=live
WORKDIR /home/onionperf

# Install system dependencies
RUN apt-get update && apt-get install -y \
cron \
automake \
wget \
build-essential \
cmake \
git \
Expand All @@ -23,15 +21,14 @@ RUN apt-get update && apt-get install -y \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /home/onionperf

# Clone and build Anon
RUN git clone https://github.com/ATOR-Development/ator-protocol.git \
&& cd ator-protocol \
&& ./scripts/ci/update-env.sh ${ANON_ENV} \
&& ./autogen.sh \
&& ./configure --disable-asciidoc \
&& make
RUN apt-get -y update \
&& echo "anon anon/terms boolean true" | debconf-set-selections \
&& apt-get -y install wget apt-transport-https \
&& . /etc/os-release \
&& wget -qO- https://deb.dmz.ator.dev/anon.asc | tee /etc/apt/trusted.gpg.d/anon.asc \
&& echo "deb [signed-by=/etc/apt/trusted.gpg.d/anon.asc] https://deb.dmz.ator.dev anon-live-$VERSION_CODENAME main" > /etc/apt/sources.list.d/anon.list \
&& apt-get -y update \
&& apt-get -y install anon

# Clone and build TGen
RUN git clone https://github.com/shadow/tgen.git \
Expand All @@ -50,25 +47,11 @@ COPY . onionperf

RUN cd onionperf \
&& pip install --no-cache-dir -r requirements.txt \
&& python setup.py install

# Set environment variables and working directory
ENV TOR_PATH="/home/onionperf/ator-protocol/src/app/anon"
ENV TGEN_PATH="/home/onionperf/tgen/build/src/tgen"
WORKDIR /home/onionperf
&& python setup.py install \
&& cd .. && rm -rf onionperf

# Expose Listen and Connect Ports
EXPOSE 9510 9520

# Mount /home/onionperf/results folder to store the results
RUN mkdir /home/onionperf/results
VOLUME /home/onionperf/results

# Add crontab to prepare the cron configuration
ADD crontab.txt /home/onionperf/crontab.txt
RUN crontab /home/onionperf/crontab.txt

COPY docker-entrypoint.sh /home/onionperf/

# Start OnionPerf when the container runs
ENTRYPOINT [ "sh", "./docker-entrypoint.sh" ]
CMD [ "onionperf", "measure", "--tgen", "/home/onionperf/tgen/build/src/tgen", "--tor", "/usr/sbin/anon", "--tgen-listen-port", "9510", "--tgen-connect-port", "9520" ]
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3'
services:
onionperf:
image: onionperf
restart: always
volumes:
- ./onionperf-data/:/home/onionperf/onionperf-data/
11 changes: 0 additions & 11 deletions docker-entrypoint.sh

This file was deleted.

84 changes: 79 additions & 5 deletions operations/deploy-live.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ job "onionperf-anon-live" {
group "onionperf-anon-live-group" {
count = 3

volume "onionperf-results" {
volume "onionperf-data" {
type = "host"
read_only = false
source = "onionperf-live"
Expand Down Expand Up @@ -37,14 +37,19 @@ job "onionperf-anon-live" {
port "listen-port" {
static = 9510
}

port "http-port" {
static = 9222
to = 80
}
}

task "onionperf-anon-live-task" {
driver = "docker"

volume_mount {
volume = "onionperf-results"
destination = "/home/onionperf/results"
volume = "onionperf-data"
destination = "/home/onionperf/onionperf-data"
read_only = false
}

Expand All @@ -59,8 +64,77 @@ job "onionperf-anon-live" {
}

resources {
cpu = 512
memory = 512
cpu = 256
memory = 256
}
}

task "onionperf-nginx-live-task" {
driver = "docker"

volume_mount {
volume = "onionperf-data"
destination = "/var/www/onionperf-data"
read_only = true
}

config {
image = "nginx"
volumes = [
"local/nginx-onionperf:/etc/nginx/conf.d/default.conf:ro"
]
ports = ["http-port"]
}

resources {
cpu = 64
memory = 64
}

service {
name = "onionperf-live"
tags = ["onionperf", "logging"]
port = "http-port"
check {
name = "onionperf nginx http server alive"
type = "tcp"
interval = "10s"
timeout = "10s"
check_restart {
limit = 10
grace = "30s"
}
}
}

template {
change_mode = "noop"
data = <<EOH
##
# The following is a simple nginx configuration to run OnionPerf.
##
server {
root /var/www/onionperf-data/htdocs;
# This option make sure that nginx will follow symlinks to the appropriate
# OnionPerf folders
autoindex on;
index index.html;
listen 0.0.0.0:80;
location / {
try_files $uri $uri/ =404;
}
location ~/\.ht {
deny all;
}
}
EOH
destination = "local/nginx-onionperf"
}
}
}
Expand Down

0 comments on commit b3b264e

Please sign in to comment.