diff --git a/.docker/pizzly-server.env.example b/.docker/pizzly-server.env.example index 51b22f9e1..e4e7cf065 100644 --- a/.docker/pizzly-server.env.example +++ b/.docker/pizzly-server.env.example @@ -1,7 +1 @@ -SERVER_HOST=http://localhost -SERVER_PORT=3004 -NODE_ENV=development -NANGO_DB_HOST=db -NANGO_DB_USER=postgres -NANGO_DB_PASSWORD=postgres -NANGO_DB_NAME=postgres \ No newline at end of file +AUTH_CALLBACK_URL=https://.eu.ngrok.io/oauth/callback diff --git a/.docker/pizzly_proxy.env.example b/.docker/pizzly_proxy.env.example deleted file mode 100644 index 30d0d3112..000000000 --- a/.docker/pizzly_proxy.env.example +++ /dev/null @@ -1,5 +0,0 @@ -NGROK_SUBDOMAIN= -NGROK_AUTH= -NGROK_PORT=3004 -NGROK_PROTOCOL=http -NGROK_DEBUG=true \ No newline at end of file diff --git a/.docker/webapp_proxy.env.example b/.docker/webapp_proxy.env.example deleted file mode 100644 index 30d0d3112..000000000 --- a/.docker/webapp_proxy.env.example +++ /dev/null @@ -1,5 +0,0 @@ -NGROK_SUBDOMAIN= -NGROK_AUTH= -NGROK_PORT=3004 -NGROK_PROTOCOL=http -NGROK_DEBUG=true \ No newline at end of file diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 3f00a4354..19393dab2 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -37,7 +37,18 @@ export PULSAR_CPP_DIR=/opt/homebrew/Cellar/libpulsar/3.1.0 ```bash pnpm install ``` -2. Environment variables. You will need to create copies of the `.env.example` files in `app/webapp` +2. Optionally, if you are testing auth (pizzly) or webhooks (webapp) then you'll need to use ngrok to proxy internet traffic to your local machine + + Get access to ngrok and then follow the instructions here to get it setup: https://ngrok.com/download (use homebrew) and make sure to authenticate. + + Then run the following scripts to start proxying: + + ```sh + ./scripts/proxy-pizzly.sh dan-pizzly-dev + ./scripts/proxy-webapp.sh dan-trigger-dev + ``` + +3. Environment variables. You will need to create copies of the `.env.example` files in `app/webapp` ```sh cp ./apps/webapp/.env.example ./apps/webapp/.env @@ -45,21 +56,19 @@ export PULSAR_CPP_DIR=/opt/homebrew/Cellar/libpulsar/3.1.0 Then you will need to fill in the fields with real values. - You also need to create three `.env` files under the `.docker` directory: + You also need to create the `pizzly-server.env` files under the `.docker` directory: ```sh cp ./.docker/pizzly-server.env.example ./.docker/pizzly-server.env - cp ./.docker/pizzly_proxy.env.example ./.docker/pizzly_proxy.env - cp ./.docker/webapp_proxy.env.example ./.docker/webapp_proxy.env ``` - 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. + Next, update the `AUTH_CALLBACK_URL` env var in the `pizzly-server.env` env file with the value provided to the `./scripts/proxy-pizzly.sh` command. Using the example above the `AUTH_CALLBACK_URL` would be `AUTH_CALLBACK_URL=https://dan-pizzly-dev.eu.ngrok.io/oauth/callback`. - 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` + If you aren't proxying pizzly according to step 2, then leave the `pizzly-server.env` file empty. - 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` + If you are proxying the webapp accroding to step 2 then in `webapp/.env`, set the `APP_ORIGIN` to the `NGROK_SUBDOMAIN` provided to the `./scripts/proxy-webapp.sh` command, e.g. `APP_ORIGIN=https://dan-trigger-dev.eu.ngrok.io` -3. Start postgresql, pulsar, pizzly server, and the two ngrok proxies +4. Start postgresql, pulsar, and pizzly server ```bash pnpm run docker:db @@ -67,17 +76,17 @@ export PULSAR_CPP_DIR=/opt/homebrew/Cellar/libpulsar/3.1.0 > **Note:** The npm script will complete while Docker sets up the container in the background. Ensure that Docker has finished and your container is running before proceeding. -4. Generate prisma schema +5. Generate prisma schema ```bash pnpm run generate ``` -5. Run the Prisma migration to the database +6. Run the Prisma migration to the database ```bash pnpm run db:migrate:deploy ``` -6. Run the first build (with dependencies via the `...` option) +7. Run the first build (with dependencies via the `...` option) ```bash pnpm run build --filter=webapp... @@ -85,7 +94,7 @@ export PULSAR_CPP_DIR=/opt/homebrew/Cellar/libpulsar/3.1.0 **Running simply `pnpm run build` will build everything, including the Remix app.** -7. Run the Remix dev server +8. Run the Remix dev server ```bash pnpm run dev --filter=webapp diff --git a/docker-compose.yml b/docker-compose.yml index 17dd129ce..c6325d660 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,20 +26,20 @@ services: restart: always env_file: - .docker/pizzly-server.env + environment: + - SERVER_HOST=http://localhost + - SERVER_PORT=3004 + - NODE_ENV=development + - NANGO_DB_HOST=db + - NANGO_DB_USER=postgres + - NANGO_DB_PASSWORD=postgres + - NANGO_DB_NAME=postgres ports: - "3004:3004" depends_on: - db networks: - app_network - pizzly_proxy: - image: wernight/ngrok - env_file: - - .docker/pizzly_proxy.env - webapp_proxy: - image: wernight/ngrok - env_file: - - .docker/webapp_proxy.env pulsar: image: apachepulsar/pulsar:2.10.2 ports: diff --git a/scripts/proxy-pizzly.sh b/scripts/proxy-pizzly.sh new file mode 100755 index 000000000..52a53676f --- /dev/null +++ b/scripts/proxy-pizzly.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +set -e -x + +ngrok http --subdomain=${1:-$NGROK_SUBDOMAIN} --region eu 3004 diff --git a/scripts/proxy-webapp.sh b/scripts/proxy-webapp.sh new file mode 100755 index 000000000..80bea6db2 --- /dev/null +++ b/scripts/proxy-webapp.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +set -e -x + +ngrok http --subdomain=${1:-$NGROK_SUBDOMAIN} --region eu 3000