Skip to content

Commit

Permalink
chore: Add beta docker tag and debian11 install script
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Sep 19, 2024
1 parent 1c52bdc commit b43daf9
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 0 additions & 14 deletions app.json

This file was deleted.

78 changes: 78 additions & 0 deletions backend/scripts/debian11.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions backend/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b43daf9

Please sign in to comment.