Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Faros CE Docker Desktop Extension #287

Merged
merged 12 commits into from Mar 10, 2023
Merged

Conversation

bidzhao
Copy link
Contributor

@bidzhao bidzhao commented Mar 3, 2023

Description

Add Faros CE Docker Desktop Extension

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist

(Delete what does not apply)

  • Have you checked to there aren't other open Pull Requests for the same update/change?
  • Have you lint your code locally before submission?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run tests with your changes locally?

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

CLA Assistant Lite bot: Thank you for your submission, we really appreciate it. Faros can accept contrbutions only from authors who accepted and signed Contributor License Agreement. Please kindly read it and accept by posting the following comment on this PR:


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@tovbinm
Copy link
Contributor

tovbinm commented Mar 3, 2023

@bidzhao thank you for the contribution!

What exactly does this functionality provide? Why are there so many files copied over? This could become a problem to maintain.

@thomas-gerber
Copy link
Contributor

@tovbinm I'll provide the context offline. @bidzhao I am looking at it now.

Copy link
Contributor

@thomas-gerber thomas-gerber left a comment

Choose a reason for hiding this comment

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

See build error

COPY docker-compose.yaml .
COPY metadata.json .
COPY docker.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

FAROS_START_SOURCE=
HASURA_URL=http://hasura:8080
LOG_LEVEL=info
METABASE_FAROS_DB_HOST=faros-db
Copy link
Contributor

Choose a reason for hiding this comment

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

@bidzhao no METABASE_PORT?
could you explain how you built this env file from the main one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, I extraced the env values from .env file with the environment variables defined by all containers in docker-comose.yaml. I didn't find anywhere METABASE_PORT is used in docker-compose.yaml, so I think we may don't need it. Please correct me if my understanding is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we could if you don't mind duplicate .env file under sub-directory.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not mind, we already have something similar here: https://github.com/faros-ai/faros-community-edition/blob/main/kube/base/faros/config/.env
We check it is the same in our git workflows, will add this one as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

Copy link
Contributor

Choose a reason for hiding this comment

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

so now, what is the difference between the docker-extension/env and the docker-extension/.env files?

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.

Some keys are different. For example, There are sth. like LOG_LEVEL: ${FAROS_INIT_LOG_LEVEL:-info} and POSTGRES_PWD=${DATABASE_PASSWORD} defined in the root docker-compose.yaml, They are FAROS_INIT_LOG_LEVEL=info and DATABASE_PASSWORD=docker in docker-extension/.env file. So they are not suitable to be re-used in env_file. That is why I have to change them to LOG_LEVEL=info and POSTGRES_PWD=docker in docker-extension/env file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Solved by passing all environment variables explicitly in the docker-compose files.

@bidzhao
Copy link
Contributor Author

bidzhao commented Mar 4, 2023

I have read the CLA Document and I hereby sign the CLA.

@thomas-gerber
Copy link
Contributor

@bidzhao 2 questions:

  1. how can we avoid the step of replacing <FAROS_CONF_DIR> ? shouldn't an .env file be picked up automatically if it is next to the compose?
  2. certain images may change depending on the machine, like the metabase image; any idea on how to incorporate it?

@bidzhao
Copy link
Contributor Author

bidzhao commented Mar 4, 2023

@bidzhao 2 questions:

1. how can we avoid the step of replacing <FAROS_CONF_DIR> ? shouldn't an `.env` file be picked up automatically if it is next to the compose?

Docker Desktop Extension starts containers with docker compose from a temporary internal directory instead of that we run command docker extension install. I googled a lot, but unfortunately no good solution found. So the only way I can think of is manual replacing it with absolute file path.

2. certain images may change depending on the machine, like [the metabase image](https://github.com/faros-ai/faros-community-edition/blob/main/start.sh#L88); any idea on how to incorporate it?

If you want to change the icon of Faros extension, then please send me the faros.svg image and I can change it (Now it is the default docker.svg). BTW, https://farosai.docker.scarf.sh/farosai/metabase-m1 looks like a websocket api, which I cannot open via browser.

@thomas-gerber
Copy link
Contributor

@bidzhao 2 questions:

1. how can we avoid the step of replacing <FAROS_CONF_DIR> ? shouldn't an `.env` file be picked up automatically if it is next to the compose?

Docker Desktop Extension starts containers with docker compose from a temporary internal directory instead of that we run command docker extension install. I googled a lot, but unfortunately no good solution found. So the only way I can think of is manual replacing it with absolute file path.

2. certain images may change depending on the machine, like [the metabase image](https://github.com/faros-ai/faros-community-edition/blob/main/start.sh#L88); any idea on how to incorporate it?

If you want to change the icon of Faros extension, then please send me the faros.svg image and I can change it (Now it is the default docker.svg). BTW, https://farosai.docker.scarf.sh/farosai/metabase-m1 looks like a websocket api, which I cannot open via browser.

For the image, I meant the container image; https://farosai.docker.scarf.sh/farosai/metabase-m1 is the container image we use for metabase when we detect the user is on an M1 mac.

@thomas-gerber
Copy link
Contributor

@bidzhao 2 questions:

1. how can we avoid the step of replacing <FAROS_CONF_DIR> ? shouldn't an `.env` file be picked up automatically if it is next to the compose?

Docker Desktop Extension starts containers with docker compose from a temporary internal directory instead of that we run command docker extension install. I googled a lot, but unfortunately no good solution found. So the only way I can think of is manual replacing it with absolute file path.

2. certain images may change depending on the machine, like [the metabase image](https://github.com/faros-ai/faros-community-edition/blob/main/start.sh#L88); any idea on how to incorporate it?

If you want to change the icon of Faros extension, then please send me the faros.svg image and I can change it (Now it is the default docker.svg). BTW, https://farosai.docker.scarf.sh/farosai/metabase-m1 looks like a websocket api, which I cannot open via browser.

For the image, I meant the container image; https://farosai.docker.scarf.sh/farosai/metabase-m1 is the container image we use for metabase when we detect the user is on an M1 mac.

Maybe the simplest given the trouble with env files is to put all the variables directly in the docker-compose file with the environment attribute.

For the local volumes, we can transform them into persistent volumes. I tested, it works (at least those that started with FAROS_CONF_DIR).

@bidzhao
Copy link
Contributor Author

bidzhao commented Mar 4, 2023

@thomas-gerber

Maybe the simplest given the trouble with env files is to put all the variables directly in the docker-compose file with the environment attribute.
Yes, I thought of this solution too. But I dropped it because that will cause lots of duplicate enviroments among containers.

For the local volumes, we can transform them into persistent volumes. I tested, it works (at least those that started with FAROS_CONF_DIR).
OK. That could be potentially good solution. Please note env_file maps host file, instead of the file inside container.

This PR removes the need to put hardcoded links to env files and volumes
in the docker-compose file.
To support metabase arm64 image being used.
Copy link
Contributor

@thomas-gerber thomas-gerber left a comment

Choose a reason for hiding this comment

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

Issues addressed

@thomas-gerber
Copy link
Contributor

overriding CLA assistant because @bidzhao signed the CLA here, even though it was not picked up by the workflow (@ogusak FYI - maybe because the PR comes from a fork?).

@thomas-gerber thomas-gerber merged commit cd925bb into faros-ai:main Mar 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants