2022-03-11 18:46:49 -05:00
# <img src="client/public/assets/logo.png" height="32px" alt="" /> Drift
2022-03-29 14:49:15 -04:00
Drift is a self-hostable Gist clone. It's also a major work-in-progress, but is completely functional.
2022-03-08 16:29:08 -05:00
2022-03-09 19:11:45 -05:00
You can try a demo at https://drift.maxleiter.com. The demo is built on master but has no database, so files and accounts can be wiped at any time.
2022-04-20 04:52:07 -04:00
If you want to contribute, need support, or want to stay updated, you can join the IRC channel at #drift on irc.libera.chat or [reach me on twitter ](https://twitter.com/Max_Leiter ). If you don't have an IRC client yet, you can use a webclient [here ](https://demo.thelounge.chat/#/connect?join=%23drift&nick=drift-user&realname=Drift%20User ).
2022-04-13 20:11:40 -04:00
< hr / >
**Contents:**
- [Setup ](#setup )
- [Development ](#development )
- [Production ](#production )
- [Environment variables ](#environment-variables )
- [Running with pm2 ](#running-with-pm2 )
- [Running with Docker ](#running-with-docker )
- [Current status ](#current-status )
2022-03-09 19:11:45 -05:00
2022-03-12 18:08:20 -05:00
## Setup
### Development
In both `server` and `client` , run `yarn` (if you need yarn, you can download it [here ](https://yarnpkg.com/ ).)
You can run `yarn dev` in either / both folders to start the server and client with file watching / live reloading.
2022-04-01 19:26:42 -04:00
To migrate the sqlite database in development, you can use `yarn migrate` to see a list of options.
2022-03-12 18:08:20 -05:00
### Production
2022-04-20 04:52:07 -04:00
`yarn build` in both `client/` and `server/` will produce production code for the client and server respectively.
2022-03-12 18:08:20 -05:00
If you're deploying the front-end to something like Vercel, you'll need to set the root folder to `client/` .
2022-04-01 19:26:42 -04:00
In production the sqlite database will be automatically migrated to the latest version.
2022-03-21 02:09:38 -04:00
### Environment Variables
You can change these to your liking.
`client/.env` :
- `API_URL` : defaults to localhost:3001, but allows you to host the front-end separately from the backend on a service like Vercel or Netlify
2022-03-21 20:20:41 -04:00
- `SECRET_KEY` : a secret key used for validating API requests that is never exposed to the browser
2022-03-21 02:09:38 -04:00
`server/.env` :
- `PORT` : the default port to start the server on (3000 by default)
2022-03-28 19:19:53 -04:00
- `NODE_ENV` : defaults to development, can be `production`
2022-03-21 02:09:38 -04:00
- `JWT_SECRET` : a secure token for JWT tokens. You can generate one [here ](https://www.grc.com/passwords.htm ).
2022-03-21 02:27:09 -04:00
- `MEMORY_DB` : if `true` , a sqlite database will not be created and changes will only exist in memory. Mainly for the demo.
2022-04-13 20:11:40 -04:00
- `REGISTRATION_PASSWORD` : if `true` , the user will be required to provide this password to sign-up, in addition to their username and account password. If it's not set, no additional password will be required.
2022-03-21 20:20:41 -04:00
- `SECRET_KEY` : the same secret key as the client
2022-04-20 04:52:07 -04:00
- `WELCOME_CONTENT` : a markdown string that's rendered on the home page
- `WELCOME_TITLE` : the file title for the post on the homepage.
2022-03-28 15:13:22 -04:00
- `ENABLE_ADMIN` : the first account created is an administrator account
2022-03-28 19:19:53 -04:00
- `DRIFT_HOME` : defaults to ~/.drift, the directory for storing the database and eventually images
2022-03-21 02:09:38 -04:00
2022-04-09 02:29:31 -04:00
### For SSO
2022-05-07 00:52:51 -04:00
- `HEADER_AUTH` : if true, enables authenthication via the HTTP header specified in `HEADER_AUTH_KEY` which is generally populated at the reverse-proxy level.
2022-04-09 02:29:31 -04:00
- `HEADER_AUTH_KEY` : if `HEADER_AUTH` is true, the header to look for the users username (like `Auth-User` )
- `HEADER_AUTH_ROLE` : if `HEADER_AUTH` is true, the header to look for the users role ("user" | "admin", at the moment)
2022-05-07 00:52:51 -04:00
- `HEADER_AUTH_WHITELISTED_IPS` : comma-separated list of IPs users can access Drift from using header authentication. Defaults to '127.0.0.1'.
2022-03-28 23:57:13 -04:00
## Running with pm2
It's easy to start Drift using [pm2 ](https://pm2.keymetrics.io/ ).
2022-03-29 14:53:39 -04:00
First, add `.env` files to `client/` and `server/` with the values you want (see the above section for possible values).
2022-03-28 23:57:13 -04:00
Then, use the following commands to start the client and server:
- `cd server && yarn build && pm2 start yarn --name drift-server --interpreter bash -- start`
- `cd ..`
- `cd client && yarn build && pm2 start yarn --name drift-client --interpreter bash -- start`
You now use `pm2 ls` to see their statuses. Refer to pm2's docs or `pm2 help` for more information.
2022-04-13 20:11:40 -04:00
## Running with Docker
The client and server each have Dockerfiles ([client](https://github.com/MaxLeiter/Drift/blob/main/client/Dockerfile), [server ](https://github.com/MaxLeiter/Drift/blob/main/server/Dockerfile )) you can use with a docker-compose; an example compose [is provided in the repository ](https://github.com/MaxLeiter/Drift/blob/main/docker-compose.yml ). It's recommended you pair running them with nginx or another reverse proxy. Also review the environment variables above and configure them to your liking.
2022-03-09 19:11:45 -05:00
## Current status
2022-03-11 21:48:40 -05:00
2022-03-13 03:39:19 -04:00
Drift is a major work in progress. Below is a (rough) list of completed and envisioned features. If you want to help address any of them, please let me know regardless of your experience and I'll be happy to assist.
2022-03-09 19:11:45 -05:00
- [x] creating and sharing private, public, unlisted posts
- [x] syntax highlighting (detected by file extension)
- [x] multiple files per post
2022-03-11 18:46:49 -05:00
- [x] uploading files via drag-and-drop
2022-03-09 19:11:45 -05:00
- [x] responsive UI
- [x] user auth
- [ ] SSO via HTTP header (Issue: [#11 ](https://github.com/MaxLeiter/Drift/issues/11 ))
2022-03-11 21:48:40 -05:00
- [x] downloading files (individually and entire posts)
2022-03-24 18:37:15 -04:00
- [x] password protected posts
2022-03-21 02:09:38 -04:00
- [x] sqlite database
2022-03-09 19:11:45 -05:00
- [ ] administrator account / settings
2022-04-13 20:11:40 -04:00
- [x] docker-compose (PRs: [#13 ](https://github.com/MaxLeiter/Drift/pull/13 ), [#75 ](https://github.com/MaxLeiter/Drift/pull/75 ))
2022-03-09 19:11:45 -05:00
- [ ] publish docker builds
- [ ] user settings
- [ ] works enough with JavaScript disabled
2022-03-24 18:37:15 -04:00
- [x] documentation
2022-03-12 18:51:31 -05:00
- [x] customizable homepage, so the demo can exist as-is but other instances can be built from the same source. Environment variable for the file contents?