Skip to content

Commit

Permalink
Merge pull request #305 from activepieces/dev
Browse files Browse the repository at this point in the history
Release 0.1.3
  • Loading branch information
abuaboud committed Jan 14, 2023
2 parents 6e43731 + e060cf4 commit 24be47c
Show file tree
Hide file tree
Showing 14 changed files with 967 additions and 41 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Expand Up @@ -2,7 +2,7 @@ version: '3.0'

services:
backend:
image: activepieces/backend:0.1.17
image: activepieces/backend:0.1.19
container_name: activepieces-backend
restart: unless-stopped
privileged: true
Expand All @@ -21,12 +21,12 @@ services:
- AP_REDIS_HOST=redis
- AP_REDIS_PORT=6379
- AP_FRONTEND_URL=http://localhost:8080
- AP_BACKEND_URL=http://localhost:8080/api
## - AP_BACKEND_URL=http://localhost:8080/api
networks:
- activepieces

frontend:
image: activepieces/frontend:0.1.72
image: activepieces/frontend:0.1.73
container_name: activepieces-frontend
restart: unless-stopped
depends_on: [ backend ]
Expand Down
18 changes: 15 additions & 3 deletions docs/self-hosting/configurations.mdx
Expand Up @@ -3,10 +3,22 @@ title: "Configurations"
description: ""
---

To configure activepieces, you will need to set some environment variables, There is file called `.env` at the root directory for our main repo.
To configure activepieces, you will need to set some environment variables, There is file called `docker-compose.yml` at the root directory for our main repo.


| Variable | Description | Default Value |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------- |
| `JWT_SECRET` | ❗️ Encryption key used for generating JWT tokens | `None` |
| `FRONTEND_URL` | ❗️ Url that will be used in webhook triggers. | `None` |
| `AP_JWT_SECRET` | ❗️ Encryption key used for generating JWT tokens | `None` |
| `AP_FRONTEND_URL` | ❗️ Url that will be used to specify redirect url. | `None` |
| `AP_BACKEND_URL` | ❗️ Url that will be used to generate webhook url. | `None` |
| `AP_POSTGRES_DATABASE` | The name of the PostgreSQL database | `activepieces` |
| `AP_POSTGRES_HOST` | The hostname or IP address of the PostgreSQL server | `postgres` |
| `AP_POSTGRES_PASSWORD` | The password for the PostgreSQL user | `A79Vm5D4p2VQHOp2gd5` |
| `AP_POSTGRES_PORT` | The port number for the PostgreSQL server | `5432` |
| `AP_POSTGRES_USERNAME` | The username for the PostgreSQL user | `postgres` |
| `AP_REDIS_HOST` | The hostname or IP address of the Redis server | `redis` |
| `AP_REDIS_PORT` | The port number for the Redis server | `6379` |

<Warning>
The backend URL plays a crucial role in the functioning of webhooks and app triggers. By default, the URL is set to the machine's IP address. To ensure proper operation, ensure that this address is accessible or specify a different URL. One possible solution for this is using a service like ngrok (https://ngrok.com/), which can be used to expose the backend port (3000) to the internet.
</Warning>
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "activepieces",
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"scripts": {
"start": "nx run backend:start & nx run frontend:start",
Expand Down
Empty file modified packages/backend/docker-compose.yml 100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion packages/backend/package.json
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "0.1.17",
"version": "0.1.19",
"description": "",
"main": "./src/index.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/resources/activepieces-engine.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/backend/src/flags/flag.service.ts
@@ -1,5 +1,6 @@
import { Flag } from "shared";
import { databaseConnection } from "../database/database-connection";
import { getBackendUrl } from "../helper/public-ip-utils";
import { system } from "../helper/system/system";
import { SystemProp } from "../helper/system/system-prop";
import { FlagEntity } from "./flag-entity";
Expand Down Expand Up @@ -28,7 +29,7 @@ export const flagService = {
flags.push(
{
id: FlagId.BACKEND_URL,
value: system.get(SystemProp.BACKEND_URL),
value: await getBackendUrl(),
created,
updated,
},
Expand Down
13 changes: 12 additions & 1 deletion packages/backend/src/helper/public-ip-utils.ts
@@ -1,11 +1,13 @@
import dns from "node:dns/promises";
import { system } from "./system/system";
import { SystemProp } from "./system/system-prop";

const GOOGLE_DNS = "216.239.32.10";
const PUBLIC_IP_ADDRESS_QUERY = "o-o.myaddr.l.google.com";

let ipMetadata: IpMetadata | undefined;

export const getPublicIp = async (): Promise<IpMetadata> => {
const getPublicIp = async (): Promise<IpMetadata> => {
if (ipMetadata !== undefined) {
return ipMetadata;
}
Expand All @@ -24,3 +26,12 @@ export const getPublicIp = async (): Promise<IpMetadata> => {
interface IpMetadata {
ip: string;
}

export const getBackendUrl = async (): Promise<string> => {
let backendUrl = system.get(SystemProp.BACKEND_URL);
if (backendUrl === undefined) {
const { ip } = await getPublicIp();
backendUrl = `http://${ip}:3000`
}
return backendUrl;
}
12 changes: 2 additions & 10 deletions packages/backend/src/helper/trigger-utils.ts
Expand Up @@ -11,9 +11,7 @@ import {
import { ActivepiecesError, ErrorCode } from "./activepieces-error";
import { flowQueue } from "../workers/flow-worker/flow-queue";
import { createContextStore } from "../store-entry/store-entry.service";
import { getPublicIp } from "./public-ip-utils";
import { system } from "./system/system";
import { SystemProp } from "./system/system-prop";
import { getBackendUrl } from "./public-ip-utils";

const EVERY_FIFTEEN_MINUTES = "* 15 * * * *";

Expand Down Expand Up @@ -166,13 +164,7 @@ const getPieceTrigger = (trigger: PieceTrigger): Trigger => {

const getWebhookUrl = async (flowId: FlowId): Promise<string> => {
const webhookPath = `v1/webhooks?flowId=${flowId}`;
let serverUrl = system.get(SystemProp.BACKEND_URL);

if (serverUrl !== undefined) {
const { ip } = await getPublicIp();
serverUrl = `http://${ip}:3000`
}

let serverUrl = await getBackendUrl();
return `${serverUrl}/${webhookPath}`;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.1.72",
"version": "0.1.73",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
Expand Up @@ -240,7 +240,7 @@ export class ConfigsFormComponent implements ControlValueAccessor {
}
}
openNewAuthenticationModal(authConfigName: string) {
this.updateOrAddConfigModalClosed$ = this.authenticationService.getServerUrl().pipe(
this.updateOrAddConfigModalClosed$ = this.authenticationService.getFrontendUrl().pipe(
switchMap(serverUrl => {
return this.dialogService
.open(NewAuthenticationModalComponent, {
Expand Down
Expand Up @@ -108,15 +108,15 @@ export class AuthenticationService {
})
);
}
getApiUrl(): Observable<string> {
getBackendUrl(): Observable<string> {
return this.getAllFlags().pipe(
map(flags => {
return flags['BACKEND_URL'] as string;
})
);
}

getServerUrl(): Observable<string> {
getFrontendUrl(): Observable<string> {
return this.getAllFlags().pipe(
map(flags => {
return flags['FRONTEND_URL'] as string;
Expand Down
Expand Up @@ -56,7 +56,7 @@ export class EditStepAccordionComponent implements AfterViewInit {
) {
this.webhookUrl$ = forkJoin({
flowId: this.store.select(BuilderSelectors.selectCurrentFlowId).pipe(take(1)),
serverUrl: this.authenticationService.getApiUrl(),
serverUrl: this.authenticationService.getBackendUrl(),
}).pipe(
map(res => {
return `${res.serverUrl}/v1/webhooks?flowId=${res.flowId}`;
Expand Down

0 comments on commit 24be47c

Please sign in to comment.