Merge pull request #1134 from AmruthPillai/feature/configure-gitpod

Configure Gitpod for easier development and self-hosting
This commit is contained in:
Amruth Pillai
2022-12-16 17:58:50 +01:00
committed by GitHub
9 changed files with 131 additions and 6 deletions

View File

@ -11,7 +11,7 @@ POSTGRES_PASSWORD=postgres
# Server
SECRET_KEY=
POSTGRES_HOST=postgres
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_SSL_CERT=
JWT_SECRET=

View File

@ -14,6 +14,7 @@
// TypeScript ESLint
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Environment Variables
.env
.env.*
!.env.gitpod
!.env.example
# Project Dependencies

41
.gitpod.yml Normal file
View File

@ -0,0 +1,41 @@
tasks:
- name: Run PostgreSQL Database
command: docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
- name: Install Project Dependencies
command: |
pnpm install
pnpm dlx playwright install --with-deps chromium
gp sync-done deps
- name: Generate Environment Variables
init: gp sync-await deps
command: |
if [ -f .env ]; then
echo "Found .env in workspace, skipping generation"
else
pnpm generate-env
fi
gp sync-done env
- name: Build and Run Project
init: gp sync-await env
command: |
pnpm build
pnpm start
ports:
# PostgreSQL
- port: 5432
onOpen: ignore
visibility: private
# Client
- port: 3100
onOpen: ignore
visibility: public
# Client
- port: 3000
onOpen: open-browser
visibility: public

View File

@ -18,7 +18,7 @@ You have complete control over what goes into your resume, how it looks, what co
## Table of Contents
- [Reactive Resume](#reactive-resume)
- [Go to App Docs](https://docs.rxresu.me)
- [Go to App | Docs](#go-to-app--docs)
- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Languages](#languages)
@ -104,6 +104,10 @@ The docs include an extensive [Tutorial](https://docs.rxresu.me/tutorial) sectio
## Build from Source
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/AmruthPillai/Reactive-Resume)
Initially building the image and project on Gitpod will take at least ~10 minutes, so please be patient on first launch.
For extensive information on how to build the app on your local machine, head over to the docs [Source Code](https://docs.rxresu.me/source-code) section.
## Contributing

View File

@ -4,10 +4,11 @@
"private": true,
"scripts": {
"dev": "env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run dev",
"lint": "turbo run lint",
"build": "env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run build",
"start": "env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run start",
"format": "prettier --write ."
"generate-env": "ts-node ./scripts/generate-env.ts",
"format": "prettier --write .",
"lint": "turbo run lint"
},
"workspaces": [
"schema",
@ -18,15 +19,18 @@
"cross-env": "^7.0.3",
"cross-var": "^1.1.0",
"env-cmd": "^10.1.0",
"turbo": "^1.6.3"
"turbo": "^1.6.3",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/node": "^18.11.15",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"eslint": "^8.29.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"prettier": "^2.8.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
},
"resolutions": {

6
pnpm-lock.yaml generated
View File

@ -8,6 +8,7 @@ importers:
.:
specifiers:
'@types/node': ^18.11.15
'@typescript-eslint/eslint-plugin': ^5.46.1
'@typescript-eslint/parser': ^5.46.1
cross-env: ^7.0.3
@ -17,20 +18,25 @@ importers:
eslint-plugin-import: ^2.26.0
eslint-plugin-simple-import-sort: ^8.0.0
prettier: ^2.8.1
ts-node: ^10.9.1
turbo: ^1.6.3
typescript: ^4.9.4
uuid: ^9.0.0
dependencies:
cross-env: 7.0.3
cross-var: 1.1.0
env-cmd: 10.1.0
turbo: 1.6.3
uuid: 9.0.0
devDependencies:
'@types/node': 18.11.15
'@typescript-eslint/eslint-plugin': 5.46.1_imrg37k3svwu377c6q7gkarwmi
'@typescript-eslint/parser': 5.46.1_ha6vam6werchizxrnqvarmz2zu
eslint: 8.29.0
eslint-plugin-import: 2.26.0_z7hwuz3w5sq2sbhy7d4iqrnsvq
eslint-plugin-simple-import-sort: 8.0.0_eslint@8.29.0
prettier: 2.8.1
ts-node: 10.9.1_ewfw2lwfc3dwdvz7r6yz2ssqyi
typescript: 4.9.4
client:

66
scripts/generate-env.ts Normal file
View File

@ -0,0 +1,66 @@
import { randomBytes } from 'crypto';
import fs from 'fs/promises';
const envMap = {
TZ: 'UTC',
PUBLIC_URL: '',
PUBLIC_SERVER_URL: '',
PUBLIC_GOOGLE_CLIENT_ID: '',
POSTGRES_DB: 'postgres',
POSTGRES_USER: 'postgres',
POSTGRES_PASSWORD: 'postgres',
SECRET_KEY: '',
POSTGRES_HOST: 'localhost',
POSTGRES_PORT: '5432',
POSTGRES_SSL_CERT: '',
JWT_SECRET: '',
JWT_EXPIRY_TIME: '604800',
GOOGLE_CLIENT_SECRET: '',
GOOGLE_API_KEY: '',
MAIL_FROM_NAME: '',
MAIL_FROM_EMAIL: '',
MAIL_HOST: '',
MAIL_PORT: '',
MAIL_USERNAME: '',
MAIL_PASSWORD: '',
STORAGE_BUCKET: '',
STORAGE_REGION: '',
STORAGE_ENDPOINT: '',
STORAGE_URL_PREFIX: '',
STORAGE_ACCESS_KEY: '',
STORAGE_SECRET_KEY: '',
PDF_DELETION_TIME: '345600000',
PUBLIC_FLAG_DISABLE_SIGNUPS: 'false',
};
const main = async () => {
// URLs
// If running in a Gitpod environment, auto generated the URLs
if (process.env.GITPOD_WORKSPACE_URL) {
const baseUrl = new URL(process.env.GITPOD_WORKSPACE_URL!).host;
envMap['PUBLIC_SERVER_URL'] = `https://3100-${baseUrl}`;
envMap['PUBLIC_URL'] = `https://3000-${baseUrl}`;
}
// Otherwise, fallback to localhost
else {
envMap['PUBLIC_SERVER_URL'] = 'https://localhost:3100';
envMap['PUBLIC_URL'] = 'https://localhost:3000';
}
// Secret Key
envMap['SECRET_KEY'] = randomBytes(20).toString('hex');
envMap['JWT_SECRET'] = randomBytes(40).toString('hex');
const envFile = Object.entries(envMap)
.reduce((acc, [key, value]) => {
acc.push(`${key}=${value}`);
return acc;
}, [] as string[])
.join('\n');
await fs.writeFile('.env', envFile);
};
main();

View File

@ -10,8 +10,10 @@ const bootstrap = async () => {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
const configService = app.get(ConfigService);
const appUrl = configService.get<string>('app.url');
// Middleware
app.enableCors({ credentials: true });
app.enableCors({ origin: [appUrl], credentials: true });
app.enableShutdownHooks();
app.use(cookieParser());