From 24895cd7c17419ecfb444d4bddc5b2fdca3057d2 Mon Sep 17 00:00:00 2001 From: April Hall Date: Mon, 24 Feb 2025 08:39:43 -0500 Subject: [PATCH] docs: Add installation documentation --- README.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++-- TODO.md | 2 +- compose.yaml | 8 ++--- 3 files changed, 88 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a84e994..c7b44a8 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,92 @@ A simple chat app built with SvelteKit and Apache Cassandra
[![Prettier](https://github.com/arithefirst/sv-chat/actions/workflows/prettier.yml/badge.svg)](https://github.com/arithefirst/sv-chat/actions/workflows/prettier.yml) [![ESLint](https://github.com/arithefirst/sv-chat/actions/workflows/eslint.yml/badge.svg)](https://github.com/arithefirst/sv-chat/actions/workflows/eslint.yml) -## Techstack +## 💻 Techstack -![Techstack](https://go-skill-icons.vercel.app/api/icons?i=cassandra,socketio,sqlite,svelte,tailwindcss,ts) +![Techstack](https://go-skill-icons.vercel.app/api/icons?i=cassandra,docker,socketio,sqlite,svelte,tailwindcss,ts) - Cassandra and SQLite for storing messages and user data respectively +- Docker for easier deployments - SvelteKit and TypeScript for backend - TailwindCSS and ShadCN Svelte for frontend - SocketIO for communication between connected clients + +## 🐋 Deploying (Docker) + +To deploy with Docker, you will need to have both `docker` and `docker-compose` installed. + +1. **Pull down the `compose.yaml` file** + + ```bash + curl https://raw.githubusercontent.com/arithefirst/svchat/refs/heads/master/compose.yaml -o compose.yml + ``` + +2. **Edit the service details**
+ Open `compose.yaml` in the editor of your choice and replace the following enviroment variables: + + - `ORIGIN`: The URL of your production deployment (no trailing slash) + - `CASSANDRA_USER`: Database Username + - `CASSANDRA_PASSWORD`: Database Password + - `MINIO_ROOT_USER`: S3 Bucket Username + - `MINIO_ROOT_PASSWORD`: S3 Bucket Password + +3. **Start the stack** + ```bash + docker-compose up -d # Starts detatched + docker-compose up # Starts attatched + ``` +4. **Done!**
+ Yes, it's really that easy! You can now access your deployment at `http://hostname:3000`, where hostname is the hostname or IP Address of your machine. + +## 🚀 Deploying (Manual) + +> [!TIP] +> This installation method is not reccomended. Unless you have a specific reason not to use Docker, we suggest you do so! Our docker image is kept fully up-to-date and gets re-built on every push to the repository. + +1. [**Setup Apache Cassandra**](https://cassandra.apache.org/doc/latest/cassandra/getting-started/cassandra-quickstart.html) +2. [**Setup Minio**](https://charts.min.io/) +3. **Clone the repo** + ```bash + git clone https://github.com/arithefirst/svchat + ``` +4. **Install deps**
+ In this example, I use [`bun`](https://bun.sh), but any NPM compatible package manager should work just fine! + ```bash + bun install + ``` +5. **Run DB Migrations**
+ Running the DB Migrations sets up the tables in the SQLite users DB, and allows for functional user authenticaton. + + ```bash + bun run migrate + ``` + +6. **Set Enviroment Variables**
+ In order for the server to connect to Cassandra and Minio, the credentials need to be set in `.env`. You will also need to set the production URL of your instance, to make sure CORS dosen't throw a fit. + + ```ini + # Example '.env' file + CASSANDRA_USER=admin + CASSANDRA_PASSWORD=admin + MINIO_ROOT_USER=minioadmin + MINIO_ROOT_PASSWORD=minioadmin + ORIGIN=http://localhost:3000 + ``` + + > [!WARNING] + > The above DB and S3 credentials are just for example, and it is highly reccomended that you change them for security purposes. + +7. **Build** + + ```bash + bun run build + ``` + +8. **Start the server** + + ```bash + bun run production + ``` + +9. **Done!**
+ You can now access your deployment at `http://hostname:3000`, where hostname is the hostname or IP Address of your machine. diff --git a/TODO.md b/TODO.md index 4906f3e..8d8cd56 100644 --- a/TODO.md +++ b/TODO.md @@ -9,7 +9,7 @@ A more complex version of this list is available [here](https://trello.com/b/kJw - [ ] Editing messages - [ ] Emoji picker - [ ] Images/Attatchments support -- [ ] Installation documentation +- [x] Installation documentation - [ ] LaTeX support - [ ] Notifications - [x] Make the damn textbox stop unfocusing on every message submit diff --git a/compose.yaml b/compose.yaml index ebf26ca..4b244e5 100644 --- a/compose.yaml +++ b/compose.yaml @@ -20,8 +20,8 @@ services: - 9042:9042 environment: # TODO Change default passwords - - CASSANDRA_USER=admin - - CASSANDRA_PASSWORD=admin + - CASSANDRA_USER: admin + - CASSANDRA_PASSWORD: admin volumes: - svchat-cassandra:/var/lib/cassandra @@ -34,8 +34,8 @@ services: - 9001:9001 environment: # TODO Change default passwords - - MINIO_ROOT_USER=minioadmin - - MINIO_ROOT_PASSWORD=minioadmin + - MINIO_ROOT_USER: minioadmin + - MINIO_ROOT_PASSWORD: minioadmin volumes: - svchat-s3:/data