diff --git a/.github/workflows/deploy_backend.yml b/.github/workflows/deploy_backend.yml index 88d060571..d654843b2 100644 --- a/.github/workflows/deploy_backend.yml +++ b/.github/workflows/deploy_backend.yml @@ -21,4 +21,4 @@ jobs: name: reacherhq/backend username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - tags: "${{ steps.vars.outputs.GITHUB_TAG }}" + tags: "${{ steps.vars.outputs.GITHUB_TAG }},beta" diff --git a/app.json b/app.json deleted file mode 100644 index 3ff06e877..000000000 --- a/app.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "check-if-email-exists", - "buildpacks": [{ "url": "emk/rust" }], - "description": "Check if an email address exists without sending any email, written in Rust", - "keywords": [ - "email", - "smtp", - "rust", - "email-validation", - "email-verification" - ], - "logo": "https://storage.googleapis.com/saasify-uploads-prod/696e287ad79f0e0352bc201b36d701849f7d55e7.svg", - "repository": "https://github.com/reacherhq/check-if-email-exists" -} diff --git a/backend/scripts/debian11.sh b/backend/scripts/debian11.sh new file mode 100644 index 000000000..9d7389f73 --- /dev/null +++ b/backend/scripts/debian11.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Install script of Reacher Backend on an OVH debian 11 server. +# As a postinstall, this script is meant to be run once, but for convenience, +# it's actually idempotent. + +# Fail early. +set -e + +# You can change the default values of these variables inline here, or by +# setting them in the environment before running this script, e.g.: +# RCH_BACKEND_NAME="my-own-name" ./debian11.sh + +# An unique identifier for the backend. +RCH_BACKEND_NAME=${RCH_BACKEND_NAME:-"backend1.mycompany.com"} +# Docker Hub tag for reacherhq/backend. +RCH_VERSION=${RCH_VERSION:-"v0.7.0"} +# Optional: Send bug reports to a Sentry.io dashboard. +RCH_SENTRY_DSN=${RCH_SENTRY_DSN:-} +# Protect the backend from the public via a `x-reacher-secret` header. +RCH_HEADER_SECRET=${RCH_HEADER_SECRET:-} +# For the "FROM" field in emails. +RCH_FROM_EMAIL=${RCH_FROM_EMAIL:-"hello@mycompany.com"} +# For the "EHLO" field in emails. This should ideally match the server's +# reverse DNS entry for optimal results. +RCH_HELLO_NAME=${RCH_HELLO_NAME:-"backend1.mycompany.com"} +# Timeout for SMTP connections in seconds. +RCH_SMTP_TIMEOUT=${RCH_SMTP_TIMEOUT:-"90"} +# Logging. Setup to "debug" to show all logs. +RUST_LOG=${RUST_LOG:-"info"} + +echo "Installing Reacher backend $RCH_VERSION on host $RCH_BACKEND_NAME..." + +# Install Docker +# https://docs.docker.com/engine/install/debian/ +sudo apt-get update +sudo apt-get upgrade --yes +sudo apt-get install \ + ca-certificates \ + curl \ + gnupg \ + lsb-release \ + --yes +sudo mkdir -p /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin --yes + +# Create `docker` group +# https://docs.docker.com/engine/install/linux-postinstall/ +getent group docker || sudo groupadd docker +sudo usermod -aG docker debian +# Reload users and groups, see +# https://superuser.com/questions/272061/reload-a-linux-users-group-assignments-without-logging-out +sudo su - $USER << EOF + +# Stop all previous docker containers and images +docker stop reacher_backend +docker rm reacher_backend + +# Run the backend +docker run -d \ + -e RUST_LOG=$RUST_LOG \ + -e RCH_BACKEND_NAME=$RCH_BACKEND_NAME \ + -e RCH_SENTRY_DSN=$RCH_SENTRY_DSN \ + -e RCH_HEADER_SECRET=$RCH_HEADER_SECRET \ + -e RCH_FROM_EMAIL=$RCH_FROM_EMAIL \ + -e RCH_HELLO_NAME=$RCH_HELLO_NAME \ + -e RCH_SMTP_TIMEOUT=$RCH_SMTP_TIMEOUT \ + -p 80:8080 \ + --name reacher_backend \ + reacherhq/backend:$RCH_VERSION + +echo "Everything set. You can close this terminal." +EOF diff --git a/backend/src/check.rs b/backend/src/check.rs index d8dacff12..e4047e276 100644 --- a/backend/src/check.rs +++ b/backend/src/check.rs @@ -62,6 +62,10 @@ pub fn check_header() -> warp::filters::BoxedFilter<()> { match env_var { Ok(secret) => { + if secret.len() == 0 { + return warp::any().boxed(); + } + let secret: &'static str = Box::leak(Box::new(secret)); warp::header::exact("x-reacher-secret", secret).boxed() diff --git a/docker.sh b/docker.sh index 63d1b3701..aabd35581 100755 --- a/docker.sh +++ b/docker.sh @@ -1,5 +1,7 @@ #!/bin/ash +# This is the Dockerfile's entrypoint script. + # https://docs.docker.com/config/containers/multi-service_container/ chromedriver & ./reacher_backend