Prod fixes

This commit is contained in:
Ben Allfree 2022-10-13 06:14:49 +00:00
parent 72057c6934
commit 82fce63dce
9 changed files with 88 additions and 5 deletions

1
.gitignore vendored
View File

@ -2,4 +2,5 @@
node_modules
.secret
.vscode
*.out
.env

72
development.md Normal file
View File

@ -0,0 +1,72 @@
# Developer instructions
## Deployment
### Clone
```bash
git clone git@github.com:benallfree/pockethost.git
cd pockethost
```
### Build custom PockeBase
```bash
cd packages/pocketbase
yarn build
```
### Build daemon
```bash
cd packages/daemon
yarn build
```
### Build web app
```bash
cd packages/pockethost.io
cp .env-template .env
nano .env
```
Edit vars as needed
```bash
yarn build
```
### Prepare Docker
```bash
cd docker
cp .env.template .env
nano .env
```
Edit `APP_DOMAIN` and `CORE_PB_PASSWORD` (needed by daemon)
Ensure that your ssl files are present there.
```bash
cd ../docker
ls ssl
```
```bash
sudo certbot --server https://acme-v02.api.letsencrypt.org/directory -d *.pockethost.io -d pockethost.io --manual --preferred-challenges dns-01 certonly
```
```bash
nano nginx-conf/nginx.conf
```
Edit as needed
## Run
```bash
sudo docker-compose up
```

View File

@ -16,10 +16,10 @@ services:
depends_on:
- pbproxy
env_file:
- ../.env
- ./.env
pbproxy:
env_file:
- ../.env
- ./.env
image: node:18
container_name: pbproxy
restart: unless-stopped

1
docker/mount/ssl/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.pem

View File

@ -3,7 +3,7 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "esbuild src/server.ts --bundle --platform=node > dist/server.js",
"build": "mkdir -p dist && esbuild src/server.ts --bundle --platform=node > dist/server.js",
"watch": "chokidar 'src/**' -c 'yarn build' --initial",
"serve": "node dist/server.js"
},

View File

@ -5,6 +5,7 @@ import { ChildProcessWithoutNullStreams, spawn } from 'child_process'
import getPort from 'get-port'
import fetch from 'node-fetch'
import {
APP_DOMAIN,
CORE_PB_PASSWORD,
CORE_PB_PORT,
CORE_PB_SUBDOMAIN,
@ -98,7 +99,12 @@ export const createInstanceManger = async () => {
heartbeat: () => {},
}
await tryFetch(coreInternalUrl)
await client.adminAuthViaEmail(CORE_PB_USERNAME, CORE_PB_PASSWORD)
try {
await client.adminAuthViaEmail(CORE_PB_USERNAME, CORE_PB_PASSWORD)}
catch(e) {
console.error(`***WARNING*** CANNOT AUTHENTICATE TO https://${CORE_PB_SUBDOMAIN}.${APP_DOMAIN}/_/`)
console.error(`***WARNING*** LOG IN MANUALLY, ADJUST .env, AND RESTART DOCKER`)
}
const limiter = new Bottleneck({ maxConcurrent: 1 })

View File

@ -3,6 +3,7 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build"
"build:arm64": "GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build",
"build:386": "GOOS=linux GOARCH=386 CGO_ENABLED=0 go build"
}
}

View File

@ -0,0 +1,2 @@
PUBLIC_APP_DOMAIN = pockethost.local
PUBLIC_CORE_PB_SUBDOMAIN = pockethost-central