OK, I am unable to compile dub-registry :D, I have only 4GB free RAM and it seems it is not enought LOL

On Wed, Jan 10, 2018 at 12:03 PM, Daniel Kozak <kozzi11@gmail.com> wrote:
Thank you :)

On Wed, Jan 10, 2018 at 11:53 AM, Seb via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On Wednesday, 10 January 2018 at 10:36:57 UTC, Daniel Kozak wrote:
I am able to provide my VPS for mirroring too. Is there a tutorial how to do it?

The dub-registry binary can be started with `--mirror=https://code.dlang.org`
Martin even an Ansible script for dub-mirror.dlang.io:

https://github.com/dlang/ci/blob/master/ansible/roles/dub_registry_mirror/tasks/main.yml

It boils down to these tasks:

1) git clone https://github.com/dlang/dub-registry
2) dub #  <- maybe -b release
3) Install mongo and start

sudo apt-get install mongodb && sudo systemctl enable mongodb && sudo systemctl start mongodb

4) Configure a systemd service

Here's my systemd service:

/etc/systemd/system/dub-registry.service

-----
[Unit]
Description=DUB registry
OnFailure=unit-status-mail@%n.service

[Service]
Environment="PORT=9001"
ExecStart=/opt/projects/dub-registry/dub-registry --port 8005 --mirror=https://code.dlang.org --hostname=code-mirror2.dlang.org --vv
WorkingDirectory=/opt/projects/dub-registry
Restart=always
RestartSec=30
User=dub-registry

[Install]
WantedBy=multi-user.target
------


[Unit]
Description=Unit Status Mailer Service
After=network.target

[Service]
Type=simple
ExecStart=/opt/bin/unit-status-mail.sh "%I" "Hostname: %H" "Machine ID: %m" "Boot ID: %b"
----


/opt/bin/unit-status-mail.sh

----
#!/bin/bash
MAILTO="root"
MAILFROM="unit-status-mailer"
UNIT=$1

EXTRA=""
for e in "${@:2}"; do
  EXTRA+="$e"$'\n'
done

UNITSTATUS=$(systemctl status $UNIT)
UNITLOG=$(journalctl -u $UNIT -r | head -n 100)

sendmail $MAILTO <<EOF
From:$MAILFROM
To:$MAILTO
Subject:Status of: $UNIT

Status report for unit: $UNIT
$EXTRA

$UNITSTATUS

$UNITLOG
EOF

echo -e "Status mail sent to: $MAILTO for unit: $UNIT"
---

5) Configure Nginx

/etc/nginx/sites-available/dub-mirror
---

server {
        listen 80;
        listen [::]:80;
        server_name code-mirror2.dlang.io;

        location / {
                proxy_pass http://localhost:8005;
        }
}
---

6) Configure Letsencrypt for SSL (optional)
7) Add yourself to this list:

https://github.com/dlang/dub/blob/master/source/dub/dub.d#L64

Note that with a few tweaks it's possible to run the dub-registry on Heroku:

https://github.com/dlang/dub-registry/pull/231