README updates
This commit is contained in:
parent
2c3e271df1
commit
3bebb6ac7d
3 changed files with 31 additions and 49 deletions
56
README.md
56
README.md
|
@ -20,18 +20,14 @@ If you want to contribute, need support, or want to stay updated, you can join t
|
||||||
|
|
||||||
### Development
|
### Development
|
||||||
|
|
||||||
In both `server` and `client`, run `yarn` (if you need yarn, you can download it [here](https://yarnpkg.com/).)
|
In the `client/` directory, run `pnpm i`. If you need `pnpm`, you can download it [here](https://pnpm.io/installation).
|
||||||
You can run `yarn dev` in either / both folders to start the server and client with file watching / live reloading.
|
You can run `pnpm dev` in `client` for file watching and live reloading.
|
||||||
|
|
||||||
To migrate the sqlite database in development, you can use `yarn migrate` to see a list of options.
|
To work with [prisma](prisma.io/), you can interface with prisma via `pnpm prisma`.
|
||||||
|
|
||||||
### Production
|
### Production
|
||||||
|
|
||||||
`yarn build` in both `client/` and `server/` will produce production code for the client and server respectively.
|
`pnpm build` in `client/` will produce production code. `pnpm start` will run the Next.js server.
|
||||||
|
|
||||||
If you're deploying the front-end to something like Vercel, you'll need to set the root folder to `client/`.
|
|
||||||
|
|
||||||
In production the sqlite database will be automatically migrated to the latest version.
|
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
|
||||||
|
@ -39,56 +35,52 @@ You can change these to your liking.
|
||||||
|
|
||||||
`client/.env`:
|
`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
|
- `DRIFT_URL`: the URL of the drift instance.
|
||||||
- `SECRET_KEY`: a secret key used for validating API requests that is never exposed to the browser
|
- `DATABASE_URL`: the URL to connect to your postgres instance. For example, `postgresql://user:password@localhost:5432/drift`.
|
||||||
|
|
||||||
`server/.env`:
|
|
||||||
|
|
||||||
- `PORT`: the default port to start the server on (3000 by default)
|
|
||||||
- `NODE_ENV`: defaults to development, can be `production`
|
|
||||||
- `JWT_SECRET`: a secure token for JWT tokens. You can generate one [here](https://www.grc.com/passwords.htm).
|
|
||||||
- `MEMORY_DB`: if `true`, a sqlite database will not be created and changes will only exist in memory. Mainly for the demo.
|
|
||||||
- `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.
|
|
||||||
- `SECRET_KEY`: the same secret key as the client
|
|
||||||
- `WELCOME_CONTENT`: a markdown string that's rendered on the home page
|
- `WELCOME_CONTENT`: a markdown string that's rendered on the home page
|
||||||
- `WELCOME_TITLE`: the file title for the post on the homepage.
|
- `WELCOME_TITLE`: the file title for the post on the homepage.
|
||||||
- `ENABLE_ADMIN`: the first account created is an administrator account
|
- `ENABLE_ADMIN`: the first account created is an administrator account
|
||||||
- `DRIFT_HOME`: defaults to ~/.drift, the directory for storing the database and eventually images
|
- `REGISTRATION_PASSWORD`: the password required to register an account. If not set, no password is required.
|
||||||
|
- `NODE_ENV`: defaults to development, can be `production`
|
||||||
|
- `GITHUB_CLIENT_ID`: the client ID for GitHub OAuth
|
||||||
|
- `GITHUB_CLIENT_SECRET`: the client secret for GitHub OAuth
|
||||||
|
- `NEXTAUTH_URL`: the URL of the drift instance.
|
||||||
|
|
||||||
## Running with pm2
|
## Running with pm2
|
||||||
|
|
||||||
It's easy to start Drift using [pm2](https://pm2.keymetrics.io/).
|
It's easy to start Drift using [pm2](https://pm2.keymetrics.io/).
|
||||||
First, add `.env` files to `client/` and `server/` with the values you want (see the above section for possible values).
|
First, add the `.env` file to `client/` with your values (see the above section for the required options).
|
||||||
Then, use the following commands to start the client and server:
|
|
||||||
|
|
||||||
- `cd server && yarn build && pm2 start yarn --name drift-server --interpreter bash -- start`
|
Then, use the following command to start the client :
|
||||||
- `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.
|
- `cd client && pnpm build && pm2 start pnpm --name drift-client --interpreter bash -- start`
|
||||||
|
|
||||||
|
Refer to pm2's docs or `pm2 help` for more information.
|
||||||
|
|
||||||
## Running with Docker
|
## 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.
|
|
||||||
|
|
||||||
## Current status
|
## Current status
|
||||||
|
|
||||||
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.
|
Drift is a 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.
|
||||||
|
|
||||||
- [x] creating and sharing private, public, unlisted posts
|
- [x] creating and sharing private, public, unlisted posts
|
||||||
- [x] syntax highlighting (detected by file extension)
|
- [x] syntax highlighting (detected by file extension)
|
||||||
- [x] multiple files per post
|
- [x] multiple files per post
|
||||||
- [x] uploading files via drag-and-drop
|
- [x] uploading files via drag-and-drop
|
||||||
|
- [x] expiring posts
|
||||||
- [x] responsive UI
|
- [x] responsive UI
|
||||||
- [x] user auth
|
- [x] user auth
|
||||||
- [ ] SSO via HTTP header (Issue: [#11](https://github.com/MaxLeiter/Drift/issues/11))
|
- [ ] SSO via HTTP header (Issue: [#11](https://github.com/MaxLeiter/Drift/issues/11))
|
||||||
- [x] downloading files (individually and entire posts)
|
- [x] downloading files (individually and entire posts)
|
||||||
- [x] password protected posts
|
- [x] password protected posts
|
||||||
- [x] sqlite database
|
- [x] postgres database
|
||||||
- [ ] administrator account / settings
|
- [x] administrator account / settings
|
||||||
- [x] docker-compose (PRs: [#13](https://github.com/MaxLeiter/Drift/pull/13), [#75](https://github.com/MaxLeiter/Drift/pull/75))
|
- [x] docker-compose (PRs: [#13](https://github.com/MaxLeiter/Drift/pull/13), [#75](https://github.com/MaxLeiter/Drift/pull/75))
|
||||||
- [ ] publish docker builds
|
- [ ] publish docker builds
|
||||||
- [ ] user settings
|
- [ ] user settings
|
||||||
- [ ] works enough with JavaScript disabled
|
- [ ] works enough with JavaScript disabled
|
||||||
- [x] documentation
|
- [ ] in-depth documentation
|
||||||
- [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?
|
- [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?
|
||||||
|
- [ ] fleshed out API
|
||||||
|
- [ ] Swappable database backends
|
||||||
|
- [ ] More OAuth providers
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
type Config = {
|
type Config = {
|
||||||
// port: number
|
|
||||||
jwt_secret: string
|
|
||||||
drift_home: string
|
|
||||||
is_production: boolean
|
is_production: boolean
|
||||||
memory_db: boolean
|
|
||||||
enable_admin: boolean
|
enable_admin: boolean
|
||||||
secret_key: string
|
|
||||||
registration_password: string
|
registration_password: string
|
||||||
welcome_content: string
|
welcome_content: string
|
||||||
welcome_title: string
|
welcome_title: string
|
||||||
url: string
|
url: string
|
||||||
GITHUB_CLIENT_ID: string
|
github_client_id: string
|
||||||
GITHUB_CLIENT_SECRET: string
|
github_client_secret: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type EnvironmentValue = string | undefined
|
type EnvironmentValue = string | undefined
|
||||||
|
@ -75,19 +70,14 @@ export const config = (env: Environment): Config => {
|
||||||
validNodeEnvs(env.NODE_ENV)
|
validNodeEnvs(env.NODE_ENV)
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
// port: env.PORT ? parseInt(env.PORT) : 3000,
|
|
||||||
jwt_secret: env.JWT_SECRET || "myjwtsecret",
|
|
||||||
drift_home: env.DRIFT_HOME || "~/.drift",
|
|
||||||
is_production,
|
is_production,
|
||||||
memory_db: stringToBoolean(env.MEMORY_DB),
|
|
||||||
enable_admin: stringToBoolean(env.ENABLE_ADMIN),
|
enable_admin: stringToBoolean(env.ENABLE_ADMIN),
|
||||||
secret_key: developmentDefault("SECRET_KEY", "secret"),
|
|
||||||
registration_password: env.REGISTRATION_PASSWORD ?? "",
|
registration_password: env.REGISTRATION_PASSWORD ?? "",
|
||||||
welcome_content: env.WELCOME_CONTENT ?? "",
|
welcome_content: env.WELCOME_CONTENT ?? "",
|
||||||
welcome_title: env.WELCOME_TITLE ?? "",
|
welcome_title: env.WELCOME_TITLE ?? "",
|
||||||
url: throwIfUndefined("DRIFT_URL"),
|
url: process.env.VERCEL_URL ?? throwIfUndefined("DRIFT_URL"),
|
||||||
GITHUB_CLIENT_ID: env.GITHUB_CLIENT_ID ?? "",
|
github_client_id: env.GITHUB_CLIENT_ID ?? "",
|
||||||
GITHUB_CLIENT_SECRET: env.GITHUB_CLIENT_SECRET ?? "",
|
github_client_secret: env.GITHUB_CLIENT_SECRET ?? "",
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import config from "@lib/config"
|
||||||
|
|
||||||
const providers: NextAuthOptions["providers"] = [
|
const providers: NextAuthOptions["providers"] = [
|
||||||
GitHubProvider({
|
GitHubProvider({
|
||||||
clientId: config.GITHUB_CLIENT_ID,
|
clientId: config.github_client_id,
|
||||||
clientSecret: config.GITHUB_CLIENT_SECRET
|
clientSecret: config.github_client_secret
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue