improve docs (closes #94)

This commit is contained in:
Akis 2023-01-10 20:58:52 +02:00
parent 6bcfb0b356
commit add264a5d6
Signed by untrusted user: akis
GPG Key ID: 267BF5C6677944ED
4 changed files with 54 additions and 35 deletions

View File

@ -1,11 +0,0 @@
AUTH_SECRET=myauthsecret # generate with https://generate-secret.vercel.app/32 or openssl rand -hex 32 on unix-like
DB_URL=mongodb://localhost:27017
GHOST_API_KEY=your-ghost-api-key
AUTH_CLIENT_ID=your-authentik-client-id
AUTH_CLIENT_SECRET=your-authentik-client-secret
AUTH_ISSUER=https://authentik-domain/application/o/app-name/
HCAPTCHA_SECRET=your-hcaptcha-secret
HCAPTCHA_SITEKEY=your-hcaptcha-sitekey
WEBHOOK=your-discord-webhook
MONGO_USER=mongodb
MONGO_PASSWORD=mongodb

View File

@ -15,6 +15,4 @@ RUN pnpm build
EXPOSE 3000
ARG ORIGIN=https://projectsegfau.lt
CMD ["node", "build/index.js"]

View File

@ -4,16 +4,50 @@ Live at [projectsegfau.lt](https://projectsegfau.lt).
## Developing
> You need a lot of infrastructure to run a complete version of the website including: Ghost CMS deployment, Authentik authentication, a Discord channel with a webhook and a hCaptcha sitekey and secret from a hCaptcha account.
### Prerequisites
- Install [node.js](https://nodejs.org).
- Install [pnpm](https://pnpm.io/) (optional, although strongly recommended).
- Install [pnpm](https://pnpm.io/).
- Install [MongoDB](https://mongodb.com).
- Learn [Svelte](https://svelte.dev).
- Add the environment variables from the [environment variables section](#environment-variables).
### Running a dev server.
1. Clone the repository using `git clone https://git.projectsegfau.lt/ProjectSegfault/website`.
1. Clone the repository using `git clone https://github.com/ProjectSegfault/website`.
2. Change directory into the clone using `cd ./website`.
3. Install dependencies using `pnpm i` (recommended) or `npm i`.
4. Run the dev server using `pnpm dev` (recommended) or `npm run dev`.
3. Install dependencies using `pnpm i`.
4. Run the dev server using `pnpm dev`.
5. Open a browser on `http://localhost:5173/` and you should see the website running locally!
## Running in production
In production you can run the website through Docker Compose or locally. We strongly recommend using Docker since it makes everything 10 times easier.
### Docker
First install Docker and Docker Compose on your system (use Linux if you are sane). After that add the environment variables from the [environment variables section](#environment-variables) and run `docker compose up -d` in the directory of the source code (or just the compose.yml file if you aren't building from source). If you are using Portainer (if you aren't, start using it) you should add a new stack in the Stacks section and select the compose file option, then copy the compose.yml file.
### Locally
If you want to run the website locally in production follow the steps in [developing](#developing) but use `node build` instead of `pnpm dev` and expect the website to be in `http://localhost:3000`.
## Environment variables
The website has the following **mandatory** environment variables
| Name | Description |
|:------------------ |:------------------------- |
| AUTH_SECRET | Random 32 char secret |
| AUTH_CLIENT_ID | Authentik client ID |
| AUTH_CLIENT_SECRET | Authentik client secret |
| AUTH_ISSUER | Authentication issuer URL |
| AUTH_TRUST_HOST | Your domain |
| HCAPTCHA_SECRET | Your hCaptcha secret |
| HCAPTCHA_SITEKEY | Your hCaptcha sitekey |
| WEBHOOK | Your Discord webhook URL |
| GHOST_API_KEY | Your Ghost CMS API key |
| DB_URL | Your MongoDB url |
| ORIGIN | Your domain |

View File

@ -1,38 +1,36 @@
services:
website:
container_name: website
#image: realprojectsegfault/website:latest
image: realprojectsegfault/website:latest # or :dev if you want to use the dev version
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile
# uncomment these lines if you want to build from source
#build:
# context: .
# dockerfile: Dockerfile
ports:
- 1339:3000
environment:
- 1339:3000 # change the first number to whatever port you want to use
environment: # these are documented in the readme
AUTH_SECRET: ${AUTH_SECRET}
AUTH_TRUST_HOST: ${AUTH_TRUST_HOST}
AUTH_URL: ${AUTH_URL}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
AUTH_CLIENT_ID: ${AUTH_CLIENT_ID}
AUTH_CLIENT_SECRET: ${AUTH_CLIENT_SECRET}
AUTH_ISSUER: ${AUTH_ISSUER}
AUTH_TRUST_HOST: ${AUTH_TRUST_HOST}
HCAPTCHA_SECRET: ${HCAPTCHA_SECRET}
HCAPTCHA_SITEKEY: ${HCAPTCHA_SITEKEY}
WEBHOOK: ${WEBHOOK}
#args: [ "ORIGIN=" ]
GHOST_API_KEY: ${GHOST_API_KEY}
DB_URL: ${DB_URL}
ORIGIN: ${ORIGIN}
website-db:
image: mongo
website-db: # this is the mongodb database container
image: mongo:6
container_name: website-db
restart: unless-stopped
volumes:
- website-db-data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: $MONGO_USER
MONGO_INITDB_ROOT_PASSWORD: $MONGO_PASSWORD
environment: # these are documented in the readme
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
MONGO_INITDB_DATABASE: website
command: [--auth]