3.3 KiB
Deployment instructions:
See CONFIGURATION.md for configuration instructions
There are three ways to deploy mCaptcha:
- Docker
- Docker compose
- Bare metal
Docker
NOTE: We'll publish pre-built images once we reach alpha
.
- Build image:
$ cd mcaptcha && docker build -t mcaptcha/mcaptcha:latest .
-
Set configuration in configuration file
-
Run image:
If you have already have a Postgres instance running, then:
docker run -p <host-machine-port>:<port-in-configuration-file> \
--add-host=database:<database-ip-addrss> \
-e RUST_LOG=debug \
-e DATABASE_URL="postgres://<db-user>:<db-password>@database:<db-port>/<db-name>" \
mcaptcha/mcaptcha:latest
If you don't have a Postgres instance running, you can either install one using a package manager or launch one with docker. A docker-compose configuration is available that will launch both a database instance mcaptcha instance.
With docker-compose
-
Follow steps above to build docker image.
-
Set database password docker-compose configuration.
-
Launch network:
$ docker-compose up -d
Bare metal:
The process is tedious, most of this will be automated with a script in the future.
1. Install postgres if you don't have it already.
2. Create new user for running mcaptcha
:
$ sudo useradd -b /srv -m -s /usr/bin/zsh mcaptcha
3. Create new user in Postgres
$ sudo -iu postgres # switch to `postgres` user
$ psql
postgres=# CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes you need single quote`;
$ createdb -O mcaptcha mcaptcha # create db 'mcaptcha' with 'mcaptcha' as owner
4. Install and load mCaptcha/cache
module:
See mCaptcha/cache
for more
details.
4. Build mcaptcha
:
To build mcaptcha
, you need the following dependencies:
- rust
- node(
v14.16.0
) - yarn(JavaScript package manager)
- make
How to build
- Install Cargo using rustup with:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Install node(
v14.16.0
) -
Install yarn(JavaScript package manager)
-
Build with make:
$ make dev-env && \
make release
5. Install package:
$ sudo cp ./target/release/mcaptcha /usr/bin/ && \
mkdir sudo /etc/mcaptcha && \
sudo cp config/default.toml /etc/mcaptcha/config.toml
6. Systemd service configuration:
- Copy the following to
/etc/systemd/system/mcaptcha.service
:
[Unit]
Description=mCaptcha: a CAPTCHA system that gives attackers a run for their money
[Service]
Type=simple
User=mcaptcha
ExecStart=/usr/bin/mcaptcha
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
Environment="RUST_LOG=info"
[Unit]
After=sound.target
Wants=network-online.target
Wants=network-online.target
Requires=postgresql.service
After=syslog.target
[Install]
WantedBy=multi-user.target
- Enable service:
$ sudo systemctl daemon-reload && \
sudo systemctl enable mcaptcha && \ # Auto startup during boot
sudo systemctl start mcaptcha
``