From 10f68bdd46648929a1208fa018acc1656ca2204f Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Thu, 12 Jan 2023 18:35:53 +0000 Subject: [PATCH] Added instructions --- LICENSE | 24 -------- README.md | 61 ++++++++++++++++++- config.env | 7 +++ docker-compose.yml | 31 ++++++++++ reverse-proxy/README.md | 3 + reverse-proxy/apache2/rallly.conf | 18 ++++++ reverse-proxy/nginx/rallly | 12 ++++ .../traefik/docker-compose.traefik.yml | 8 +++ 8 files changed, 139 insertions(+), 25 deletions(-) delete mode 100644 LICENSE create mode 100644 config.env create mode 100644 docker-compose.yml create mode 100644 reverse-proxy/README.md create mode 100644 reverse-proxy/apache2/rallly.conf create mode 100644 reverse-proxy/nginx/rallly create mode 100644 reverse-proxy/traefik/docker-compose.traefik.yml diff --git a/LICENSE b/LICENSE deleted file mode 100644 index fdddb29..0000000 --- a/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to diff --git a/README.md b/README.md index 1f885ac..9de4003 100644 --- a/README.md +++ b/README.md @@ -1 +1,60 @@ -# self-host \ No newline at end of file +[← Go to main repository](https://github.com/lukevella/rallly) + +# Hosting your own instance of Rallly + +The best way to run Rallly on your own server is using the public image published on docker hub. This repo contains an example configuration that allows you to get your own instance of Rallly running in just a few simple steps. + +## Requirements + +You will need: + +- Docker +- Access to an SMTP server for sending emails + +## Setup + +### Copy this project + +Copy the contents of this repo on to your server or clone this repo with git: + +``` +git clone https://github.com/rallly/self-hosting.git +``` + +Feel free to name the contents of this folder to whatever your prefer. + +### Configure the environment variables + +In the root of this project you will find a file called `config.env`. Open this file with a text editor and: + +- Set `SECRET_PASSWORD` - This should be a randomly generated string that will be used to encrypt user sessions. **It should be at least 32 characters long**. + +- Set `NEXT_PUBLIC_BASE_URL` - This is the URL you will type in your browser to access your instance (eg. `https://rallly.example.com`). To be able to access the site using your own domain you will want to use a [reverse proxy](/reverse-proxy/). + +- Set `SUPPORT_EMAIL` - This will appear as the support email in emails sent out by your instance. + +- Configure `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER` and `SMTP_PWD` with the details of your SMTP server. + +### Start the server + +You can start the server by running: + +``` +docker compose up -d +``` + +This command will: + +- Create a postgres database +- Run migrations to set up the database schema +- Start the Next.js server on port 3000 + +## Updating your instance + +Rallly is constantly being updated but you will need to manually pull these updates and restart the server to run the latest version. You can do this by running the following commands from within this directory: + +``` +docker compose down +docker compose pull +docker compose up -d +``` diff --git a/config.env b/config.env new file mode 100644 index 0000000..c8d9dbe --- /dev/null +++ b/config.env @@ -0,0 +1,7 @@ +SECRET_PASSWORD=replace-me +NEXT_PUBLIC_BASE_URL=replace-me +SUPPORT_EMAIL=replace-me +SMTP_HOST=replace-me +SMTP_PORT=replace-me +SMTP_USER=replace-me +SMTP_PWD=replace-me diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5c675d0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +services: + rallly_db: + image: postgres:14.2 + restart: always + volumes: + - db-data:/var/lib/postgresql/data + environment: + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=db + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 + + rallly: + image: lukevella/rallly:latest + restart: always + depends_on: + rallly_db: + condition: service_healthy + ports: + - 3000:3000 + environment: + - DATABASE_URL=postgres://postgres:postgres@rallly_db:5432/db + env_file: + - config.env + +volumes: + db-data: + driver: local diff --git a/reverse-proxy/README.md b/reverse-proxy/README.md new file mode 100644 index 0000000..be48939 --- /dev/null +++ b/reverse-proxy/README.md @@ -0,0 +1,3 @@ +# Using a reverse proxy + +A reverse proxy can enable yourself and others to access your instance of Rallly with your own domain name. This directory contains a few example configurations for various reverse proxies. diff --git a/reverse-proxy/apache2/rallly.conf b/reverse-proxy/apache2/rallly.conf new file mode 100644 index 0000000..18fdb50 --- /dev/null +++ b/reverse-proxy/apache2/rallly.conf @@ -0,0 +1,18 @@ + + + ServerAdmin admin@example.com + ServerName example.com + + ProxyPreserveHost On + ProxyPass / http://localhost:3000/ + ProxyPassReverse / http://localhost:3000/ + + SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" forwarded + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined env=!forwarded + CustomLog ${APACHE_LOG_DIR}/access.log forwarded env=forwarded + + diff --git a/reverse-proxy/nginx/rallly b/reverse-proxy/nginx/rallly new file mode 100644 index 0000000..0ecc1c5 --- /dev/null +++ b/reverse-proxy/nginx/rallly @@ -0,0 +1,12 @@ +server { + # replace example.com with your domain name + server_name example.com; + + listen 80; + listen [::]:80; + + location / { + proxy_pass http://127.0.0.1:3000; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} diff --git a/reverse-proxy/traefik/docker-compose.traefik.yml b/reverse-proxy/traefik/docker-compose.traefik.yml new file mode 100644 index 0000000..9b3453c --- /dev/null +++ b/reverse-proxy/traefik/docker-compose.traefik.yml @@ -0,0 +1,8 @@ +version: "3.3" +services: + rallly: + labels: + traefik.enable: "true" + traefik.http.routers.plausible.rule: "Host(`example.com`)" # change to your domain name + traefik.http.routers.plausible.entrypoints: "websecure" + traefik.http.services.plausible.loadbalancer.server.port: "3000"