Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Faros CE Docker Desktop Extension #287

Merged
merged 12 commits into from
Mar 10, 2023
170 changes: 170 additions & 0 deletions docker-extension/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# This file needs to be both in the root of the repository
# and in kube/base/faros/config
# until there is support for removing load restrictions in remote directories
# see: https://github.com/kubernetes-sigs/kustomize/issues/4052
# and: https://github.com/faros-ai/faros-community-edition/issues/193
COMPOSE_PROFILES="airbyte,default,faros-db"

############################## Faros ##########################################
# The db_host, db_port, db_user and db_pass are identical to those used by Airbyte.
# This is because we use a single db service for the Faros Community Edition deployment and host all required databases
# on the same host. That service is faros-db, which extends the airbyte db service.
# These can be overriden as needed.
# Note that hosts (faros host, faros config host, airbyte host) MUST correspond a service running postgres.
FAROS_CONFIG_DB_HOST=faros-db
FAROS_CONFIG_DB_PORT=5432
FAROS_CONFIG_DB_USER=docker
FAROS_CONFIG_DB_PASSWORD=docker
FAROS_DB_NAME=faros
FAROS_DB_HOST=faros-db
FAROS_DB_PORT=5432
FAROS_DB_USER=docker
FAROS_DB_PASSWORD=docker
FAROS_INIT_LOG_LEVEL=info
FAROS_AIRBYTE_FORCE_SETUP=false
FAROS_INIT_IMAGE=farosai/faros-ce-init:latest

############################## Airbyte ########################################
VERSION=0.39.37-alpha
# Airbyte Internal Job Database, see https://docs.airbyte.io/operator-guides/configuring-airbyte-db
DATABASE_USER=docker
DATABASE_PASSWORD=docker
DATABASE_HOST=faros-db
DATABASE_PORT=5432
DATABASE_DB=airbyte
# translate manually DATABASE_URL=jdbc:postgresql://${DATABASE_HOST}:${DATABASE_PORT/${DATABASE_DB} (do not include the username or password here)
DATABASE_URL=jdbc:postgresql://faros-db:5432/airbyte
# Host must correspond to the service name running webapp
AIRBYTE_URL=http://airbyte-webapp:80
AIRBYTE_DESTINATION_HASURA_URL=http://localhost:8080

############################## Hasura #########################################
HASURA_DB_NAME=hasura
HASURA_PORT=8080
HASURA_GRAPHQL_ADMIN_SECRET=admin
HASURA_URL=http://hasura:8080
HASURA_VERSION=v2.1.1

############################## Metabase #######################################
METABASE_IMAGE="metabase/metabase"
METABASE_VERSION=v0.45.2.1
METABASE_DB_NAME=metabase
METABASE_PORT=3000
METABASE_USER=admin@admin.com
METABASE_PASSWORD=admin
METABASE_URL=http://metabase:3000
METABASE_USE_SSL=false
# The db_host used in Metabase to connect to the Faros database.
METABASE_FAROS_DB_HOST=faros-db

############################## n8n ############################################
N8N_DB_NAME=n8n
N8N_PORT=5678
N8N_VERSION=0.164.1
N8N_DOCKER_MOUNT=n8n_data

############################## AirByte default config #########################
# This file only contains Docker relevant variables.
#
# Variables with defaults have been omitted to avoid duplication of defaults.
# The only exception to the non-default rule are env vars related to scaling.
#
# See https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/java/io/airbyte/config/Configs.java
# for the latest environment variables.
#
# # Contributors - please organise this env file according to the above linked file.

# Source: https://github.com/airbytehq/airbyte/blob/v0.39.37-alpha/.env

### SHARED ###

# When using the airbyte-db via default docker image
CONFIG_ROOT=/data
DATA_DOCKER_MOUNT=airbyte_data
DB_DOCKER_MOUNT=airbyte_db

# Workspace storage for running jobs (logs, etc)
WORKSPACE_ROOT=/tmp/workspace
WORKSPACE_DOCKER_MOUNT=airbyte_workspace

# Local mount to access local files from filesystem
# todo (cgardens) - when we are mount raw directories instead of named volumes, *_DOCKER_MOUNT must
# be the same as *_ROOT.
# Issue: https://github.com/airbytehq/airbyte/issues/578
LOCAL_ROOT=/tmp/airbyte_local
LOCAL_DOCKER_MOUNT=/tmp/airbyte_local
# todo (cgardens) - hack to handle behavior change in docker compose. *_PARENT directories MUST
# already exist on the host filesystem and MUST be parents of *_ROOT.
# Issue: https://github.com/airbytehq/airbyte/issues/577
HACK_LOCAL_ROOT_PARENT=/tmp


### DATABASE ###
JOBS_DATABASE_MINIMUM_FLYWAY_MIGRATION_VERSION=0.29.15.001

# Airbyte Internal Config Database, defaults to Job Database if empty. Explicitly left empty to mute docker compose warnings.
CONFIG_DATABASE_USER=
CONFIG_DATABASE_PASSWORD=
CONFIG_DATABASE_URL=
CONFIGS_DATABASE_MINIMUM_FLYWAY_MIGRATION_VERSION=0.35.15.001

### AIRBYTE SERVICES ###
TEMPORAL_HOST=airbyte-temporal:7233
INTERNAL_API_HOST=airbyte-server:8001
WEBAPP_URL=http://localhost:8000/
# Although not present as an env var, required for webapp configuration.
API_URL=/api/v1/


### JOBS ###
# Relevant to scaling.
SYNC_JOB_MAX_ATTEMPTS=1
SYNC_JOB_MAX_TIMEOUT_DAYS=1
JOB_MAIN_CONTAINER_CPU_REQUEST=
JOB_MAIN_CONTAINER_CPU_LIMIT=
JOB_MAIN_CONTAINER_MEMORY_REQUEST=
JOB_MAIN_CONTAINER_MEMORY_LIMIT=


### LOGGING/MONITORING/TRACKING ###
TRACKING_STRATEGY=logging
JOB_ERROR_REPORTING_STRATEGY=logging
# Although not present as an env var, expected by Log4J configuration.
LOG_LEVEL=INFO


### APPLICATIONS ###
# Worker #
# Relevant to scaling.
MAX_SYNC_WORKERS=5
MAX_SPEC_WORKERS=5
MAX_CHECK_WORKERS=5
MAX_DISCOVER_WORKERS=5
# Temporal Activity configuration
ACTIVITY_MAX_ATTEMPT=
ACTIVITY_INITIAL_DELAY_BETWEEN_ATTEMPTS_SECONDS=
ACTIVITY_MAX_DELAY_BETWEEN_ATTEMPTS_SECONDS=
WORKFLOW_FAILURE_RESTART_DELAY_SECONDS=


### FEATURE FLAGS ###
AUTO_DISABLE_FAILING_CONNECTIONS=false
EXPOSE_SECRETS_IN_EXPORT=false
FORCE_MIGRATE_SECRET_STORE=false

### MONITORING FLAGS ###
# Accepted values are datadog and otel (open telemetry)
METRIC_CLIENT=
# Useful only when metric client is set to be otel. Must start with http:// or https://.
OTEL_COLLECTOR_ENDPOINT="http://host.docker.internal:4317"

USE_STREAM_CAPABLE_STATE=false

# extra settings to limit warnings during CE startup
PAPERCUPS_STORYTIME=disabled
RUN_DATABASE_MIGRATION_ON_STARTUP=true
SECRET_PERSISTENCE=NONE
WORKER_ENVIRONMENT=docker
NEW_SCHEDULER=
DEPLOYMENT_MODE=
JOB_ERROR_REPORTING_SENTRY_DSN=
31 changes: 31 additions & 0 deletions docker-extension/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM --platform=$BUILDPLATFORM node:17.7-alpine3.14 AS client-builder
ARG TARGETARCH
WORKDIR /ui
# cache packages in layer
COPY ui/package.json /ui/package.json
COPY ui/package-lock.json /ui/package-lock.json
RUN --mount=type=cache,target=/usr/src/app/.npm \
npm set cache /usr/src/app/.npm && \
npm ci
# install
COPY ui /ui
RUN npm run build
COPY docker-compose_${TARGETARCH}.yaml /compose/docker-compose.yaml

FROM alpine
LABEL org.opencontainers.image.title="Faros" \
org.opencontainers.image.description="Faros extension for Docker Desktop" \
org.opencontainers.image.vendor="Faros AI, Inc." \
com.docker.desktop.extension.api.version="0.3.3" \
com.docker.extension.screenshots="[{\"alt\":\"Faros Architecture\",\"url\":\"https://raw.githubusercontent.com/faros-ai/faros-community-edition/main/img/architecture.png\"}]" \
com.docker.extension.detailed-description="" \
com.docker.extension.publisher-url="https://github.com/faros-ai/faros-community-edition" \
com.docker.extension.additional-urls="" \
com.docker.extension.changelog="" \
com.docker.desktop.extension.icon="https://raw.githubusercontent.com/faros-ai/faros-community-edition/main/img/faros.ico" \
com.docker.extension.categories="utility-tools"

COPY --from=client-builder /compose/docker-compose.yaml .
COPY metadata.json .
COPY faros.svg .
COPY --from=client-builder /ui/dist ui
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bidzhao this errors out when I run docker build --tag=faros/extension:latest .

 => ERROR [stage-1 5/5] COPY --from=client-builder /ui/dist ui             0.0s
------
 > [stage-1 5/5] COPY --from=client-builder /ui/dist ui:
------
failed to compute cache key: "/ui/dist" not found: not found

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you execute "docker system prune -y" and try again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was no -y option, so I ran
docker system prune -a
and
docker system prune --volumes

Afterwards, same issue.

Copy link
Contributor Author

@bidzhao bidzhao Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I mean "docker image prune -a -f" and "docker system prune -a -f". I couldn't reproduce it locally. Could you please share your full build logs and your local env information, e.g. OS, docker version...? Here is my docker version:

$ docker version
Client:
Cloud integration: v1.0.31
Version: 20.10.23
API version: 1.41
Go version: go1.18.10
Git commit: 7155243
Built: Thu Jan 19 17:35:19 2023
OS/Arch: darwin/amd64
Context: default
Experimental: true

Server: Docker Desktop 4.17.0 (99724)
Engine:
Version: 20.10.23
API version: 1.41 (minimum version 1.12)
Go version: go1.18.10
Git commit: 6051f14
Built: Thu Jan 19 17:32:04 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.18
GitCommit: 2456e983eb9e37e47538f59ea18f2043c9a73640
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0

And here is my build log:

$ docker build --tag=faros/extension:latest .
[+] Building 100.3s (18/18) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 84B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 1.3s
=> [internal] load metadata for docker.io/library/node:17.7-alpine3.14 0.0s
=> [stage-1 1/5] FROM docker.io/library/alpine@sha256:69665d02cb32192e52e07644d76bc6f25abeb5410edc1c7a81a10ba3f0efb90a 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 1.50MB 0.1s
=> [client-builder 1/7] FROM docker.io/library/node:17.7-alpine3.14 0.1s
=> [client-builder 2/7] WORKDIR /ui 0.1s
=> CACHED [stage-1 2/5] COPY docker-compose.yaml . 0.0s
=> CACHED [stage-1 3/5] COPY metadata.json . 0.0s
=> [stage-1 4/5] COPY docker.svg . 0.1s
=> [client-builder 3/7] COPY ui/package.json /ui/package.json 0.0s
=> [client-builder 4/7] COPY ui/package-lock.json /ui/package-lock.json 0.0s
=> [client-builder 5/7] RUN --mount=type=cache,target=/usr/src/app/.npm npm set cache /usr/src/app/.npm && npm ci 55.9s
=> [client-builder 6/7] COPY ui /ui 0.1s
=> [client-builder 7/7] RUN npm run build 41.0s
=> [stage-1 5/5] COPY --from=client-builder /ui/dist ui 0.1s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => writing image sha256:15f5df9e1334307de443edb42a0024048596ceb7737b172c88c072d073deaea8 0.0s
=> => naming to docker.io/faros/extension:latest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bidzhao

=> [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 1.02kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => [internal] load metadata for docker.io/library/alpine:latest           3.1s
 => [internal] load metadata for docker.io/library/node:17.7-alpine3.14    3.1s
 => [client-builder 1/7] FROM docker.io/library/node:17.7-alpine3.14@sha2  3.0s
 => => resolve docker.io/library/node:17.7-alpine3.14@sha256:539e64749f7d  0.0s
 => => sha256:539e64749f7dc6c578d744d879fd0ec37f3afe552ae 1.43kB / 1.43kB  0.0s
 => => sha256:ce3358b66925f144108f66802a25e737a5ac991bf77 1.16kB / 1.16kB  0.0s
 => => sha256:ed51fad11ee87160e0d69d19e6a6be7420b4965a516 6.59kB / 6.59kB  0.0s
 => => sha256:93a1719cf26168d3a85db2594d76b17ccc4b2599662 2.72MB / 2.72MB  0.3s
 => => sha256:d2265413694a4d0534e08f3e9e2905b3f1aaa2764 45.80MB / 45.80MB  2.0s
 => => extracting sha256:93a1719cf26168d3a85db2594d76b17ccc4b25996620bcee  0.1s
 => => sha256:fde43f4aec85f9b625dfdc638777e23463ce71d6485 2.41MB / 2.41MB  0.8s
 => => sha256:d2b665bc6eb16560a5048ef9659e50d863af154e2c4cb0b 450B / 450B  0.8s
 => => extracting sha256:d2265413694a4d0534e08f3e9e2905b3f1aaa2764a1a5c75  0.7s
 => => extracting sha256:fde43f4aec85f9b625dfdc638777e23463ce71d648577b2d  0.1s
 => => extracting sha256:d2b665bc6eb16560a5048ef9659e50d863af154e2c4cb0bc  0.0s
 => [internal] load build context                                          0.1s
 => => transferring context: 1.48MB                                        0.1s
 => [stage-1 1/5] FROM docker.io/library/alpine@sha256:69665d02cb32192e52  0.5s
 => => resolve docker.io/library/alpine@sha256:69665d02cb32192e52e07644d7  0.0s
 => => sha256:c41ab5c992deb4fe7e5da09f67a8804a46bd0592bfdf0b1 528B / 528B  0.0s
 => => sha256:d74e625d91152966d38fe8a62c60daadb96d4b94c1a 1.49kB / 1.49kB  0.0s
 => => sha256:af6eaf76a39c2d3e7e0b8a0420486e3df33c4027d69 3.26MB / 3.26MB  0.3s
 => => sha256:69665d02cb32192e52e07644d76bc6f25abeb5410ed 1.64kB / 1.64kB  0.0s
 => => extracting sha256:af6eaf76a39c2d3e7e0b8a0420486e3df33c4027d696c076  0.1s
 => [stage-1 2/5] COPY docker-compose.yaml .                               0.1s
 => [stage-1 3/5] COPY metadata.json .                                     0.0s
 => [stage-1 4/5] COPY docker.svg .                                        0.0s
 => [client-builder 2/7] WORKDIR /ui                                       0.2s
 => [client-builder 3/7] COPY ui/package.json /ui/package.json             0.0s
 => [client-builder 4/7] COPY ui/package-lock.json /ui/package-lock.json   0.0s
 => [client-builder 5/7] RUN --mount=type=cache,target=/usr/src/app/.npm  27.3s
 => [client-builder 6/7] COPY ui /ui                                       0.0s
 => [client-builder 7/7] RUN npm run build                                18.8s
 => ERROR [stage-1 5/5] COPY --from=client-builder /ui/dist ui             0.0s
------
 > [stage-1 5/5] COPY --from=client-builder /ui/dist ui:
------
failed to compute cache key: "/ui/dist" not found: not found
thomasgerber@Thomass-MacBook-Pro-2 docker-extension % docker version
Client:
 Cloud integration: v1.0.29
 Version:           20.10.22
 API version:       1.41
 Go version:        go1.18.9
 Git commit:        3a2c30b
 Built:             Thu Dec 15 22:28:41 2022
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.16.2 (95914)
 Engine:
  Version:          20.10.22
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.9
  Git commit:       42c8b31
  Built:            Thu Dec 15 22:25:43 2022
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.14
  GitCommit:        9ba4b250366a5ddde94bb7c9d1def331423aa323
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it is my fault that .env file was missed for React. I have added it with commit of cc7130f

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok it works now

28 changes: 28 additions & 0 deletions docker-extension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
IMAGE?=farosai/faros-ce-docker-extension
TAG?=latest

BUILDER=buildx-multi-arch

INFO_COLOR = \033[0;36m
NO_COLOR = \033[m

build-extension: ## Build service image to be deployed as a desktop extension
docker build --tag=$(IMAGE):$(TAG) .

install-extension: build-extension ## Install the extension
docker extension install $(IMAGE):$(TAG)

update-extension: build-extension ## Update the extension
docker extension update $(IMAGE):$(TAG)

prepare-buildx: ## Create buildx builder for multi-arch build, if not exists
docker buildx inspect $(BUILDER) || docker buildx create --name=$(BUILDER) --driver=docker-container --driver-opt=network=host

push-extension: prepare-buildx ## Build & Upload extension image to hub. Do not push if tag already exists: make push-extension tag=0.1
docker pull $(IMAGE):$(TAG) && echo "Failure: Tag already exists" || docker buildx build --push --builder=$(BUILDER) --platform=linux/amd64,linux/arm64 --build-arg TAG=$(TAG) --tag=$(IMAGE):$(TAG) .

help: ## Show this help
@echo Please specify a build target. The choices are:
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}'

.PHONY: help
29 changes: 29 additions & 0 deletions docker-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Faros CE Docker Desktop Extension

See Docker extension SDK, especially the UI and VM sections of the metadata.
* The difference between the docker-compose files is the metabase image used.
* The docker-compose files are copies of the original one with all parameters set. It is not possible to easily pass environment variables to the extension.

## Installation

1. Build Docker image

```shell
docker build --tag=farosai/faros-ce-docker-extension:latest .
```

2. Install extension

```shell
docker extension install farosai/faros-ce-docker-extension:latest
```

## Clean up

```shell
docker extension rm farosai/faros-ce-docker-extension:latest
```

## Further reading
Docker extension SDK, especially the UI and VM sections of the metadata
We use different docker-compose files
Loading