Skip to content

Commit 458ee1c

Browse files
committed
Move ngrok to docker compose
1 parent 777d026 commit 458ee1c

File tree

10 files changed

+47
-49
lines changed

10 files changed

+47
-49
lines changed

.docker/pizzly-server.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SERVER_HOST=http://localhost
2+
SERVER_PORT=3004
3+
NODE_ENV=development
4+
PIZZLY_DB_HOST=db
5+
PIZZLY_DB_USER=postgres
6+
PIZZLY_DB_PASSWORD=postgres
7+
PIZZLY_DB_NAME=postgres

.docker/pizzly_proxy.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NGROK_SUBDOMAIN=<custom subdomain>
2+
NGROK_AUTH=<auth token>
3+
NGROK_PORT=3004
4+
NGROK_PROTOCOL=http
5+
NGROK_DEBUG=true

.docker/webapp_proxy.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NGROK_SUBDOMAIN=<custom subdomain>
2+
NGROK_AUTH=<auth token>
3+
NGROK_PORT=3004
4+
NGROK_PROTOCOL=http
5+
NGROK_DEBUG=true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ yarn-error.log*
3131

3232
# local env files
3333
.env.docker
34+
.docker/*.env
3435
.env.local
3536
.env.development.local
3637
.env.test.local

DEVELOPMENT.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,21 @@ export PULSAR_CPP_DIR=/opt/homebrew/Cellar/libpulsar/3.1.0
4545

4646
Then you will need to fill in the fields with real values.
4747

48-
3. Start postgresql, pulsar, and the pizzly server
48+
You also need to create three `.env` files under the `.docker` directory:
49+
50+
```sh
51+
cp ./.docker/pizzly-server.env.example ./.docker/pizzly-server.env
52+
cp ./.docker/pizzly_proxy.env.example ./.docker/pizzly_proxy.env
53+
cp ./.docker/webapp_proxy.env.example ./.docker/webapp_proxy.env
54+
```
55+
56+
In `webapp_proxy` and `pizzly_proxy` make sure you fill in the `NGROK_SUBDOMAIN` and `NGROK_AUTH` environment variables. For example, in `webapp_proxy` and `pizzly_proxy` you could have something like `dan-trigger-dev` and `dan-pizzly-dev` respectively for the `NGROK_SUBDOMAIN` env var.
57+
58+
Next, update the `SERVER_HOST` env var in the `pizzly-server.env` env file with the value provided to the `NGROK_SUBDOMAIN` in the `pizzly_proxy.env` file. Using the example above the `SERVER_HOST` would be `SERVER_HOST=https://dan-pizzly-dev.ngrok.io`
59+
60+
Also, in `webapp/.env`, set the `APP_ORIGIN` to the `NGROK_SUBDOMAIN` provided to the `webapp_proxy.env` file, e.g. `APP_ORIGIN=https://dan-trigger-dev.ngrok.io`
61+
62+
3. Start postgresql, pulsar, pizzly server, and the two ngrok proxies
4963

5064
```bash
5165
pnpm run docker:db

apps/webapp/app/entry.server.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { RemixServer } from "@remix-run/react";
33
import { renderToString } from "react-dom/server";
44
import * as Sentry from "@sentry/remix";
55
import * as MessageBroker from "~/services/messageBroker.server";
6-
import * as WebhookProxy from "~/services/webhookProxy.server";
76
import { prisma } from "./db.server";
87

98
export default function handleRequest(
@@ -37,4 +36,3 @@ if (process.env.NODE_ENV === "production" && process.env.SENTRY_DSN) {
3736
}
3837

3938
MessageBroker.init();
40-
WebhookProxy.init();

apps/webapp/app/env.server.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ const EnvironmentSchema = z.object({
3030
.string()
3131
.default("0")
3232
.transform((v) => v === "1"),
33-
NGROK_AUTH_TOKEN: z.string().optional(),
34-
NGROK_SUBDOMAIN: z.string().optional(),
3533
});
3634

3735
export type Environment = z.infer<typeof EnvironmentSchema>;

apps/webapp/app/services/externalSources/registerExternalSource.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { github } from "internal-integrations";
33
import crypto from "node:crypto";
44
import type { PrismaClient } from "~/db.server";
55
import { prisma } from "~/db.server";
6+
import { env } from "~/env.server";
67
import { findExternalSourceById } from "~/models/externalSource.server";
78
import { pizzly } from "../pizzly.server";
8-
import { originOrProxyUrl } from "../webhookProxy.server";
99

1010
export class RegisterExternalSource {
1111
#prismaClient: PrismaClient;
@@ -53,7 +53,7 @@ export class RegisterExternalSource {
5353

5454
const secret = crypto.randomBytes(32).toString("hex");
5555

56-
const webhookUrl = `${originOrProxyUrl}/api/v1/internal/webhooks/${connection.apiIdentifier}/${externalSource.id}`;
56+
const webhookUrl = `${env.APP_ORIGIN}/api/v1/internal/webhooks/${connection.apiIdentifier}/${externalSource.id}`;
5757

5858
const serviceWebhook = await this.#registerWebhookWithConnection(
5959
externalSource.service,

apps/webapp/app/services/webhookProxy.server.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

docker-compose.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,25 @@ services:
2121
networks:
2222
- app_network
2323
pizzly-server:
24-
image: nangohq/pizzly-server:0.4.3
24+
image: nangohq/pizzly-server
2525
container_name: pizzly-server
2626
restart: always
27-
environment:
28-
- SERVER_HOST=http://localhost
29-
- SERVER_PORT=3004
30-
- NODE_ENV=development
31-
- NANGO_DB_HOST=db
32-
- NANGO_DB_USER=postgres
33-
- NANGO_DB_PASSWORD=postgres
34-
- NANGO_DB_NAME=postgres
27+
env_file:
28+
- .docker/pizzly-server.env
3529
ports:
3630
- "3004:3004"
3731
depends_on:
3832
- db
3933
networks:
4034
- app_network
35+
pizzly_proxy:
36+
image: wernight/ngrok
37+
env_file:
38+
- .docker/pizzly_proxy.env
39+
webapp_proxy:
40+
image: wernight/ngrok
41+
env_file:
42+
- .docker/webapp_proxy.env
4143
pulsar:
4244
image: apachepulsar/pulsar:2.10.2
4345
ports:
@@ -50,6 +52,7 @@ services:
5052
tty: true
5153
stdin_open: true
5254
restart: always
55+
5356

5457
networks:
5558
app_network:

0 commit comments

Comments
 (0)