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

feat: add appapi-dsp/appapi-dsp-https service #337

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ node_modules/
/tests/playwright-report/
/tests/blob-report/
/tests/playwright/.cache/
/.idea/
.DS_Store
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,40 @@ services:
VIRTUAL_PORT: 1234
shm_size: 2147483648

appapi-dsp:
image: ghcr.io/cloud-py-api/nextcloud-appapi-dsp:release
container_name: nextcloud-appapi-dsp-http
network_mode: ${NETWORK_MODE:-master_default}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- NC_HAPROXY_PASSWORD=${NC_HAPROXY_PASSWORD:-some_secure_password}
- BIND_ADDRESS=${BIND_ADDRESS:-}
- HAPROXY_PORT=${HAPROXY_PORT:-2375}
- TIMEOUT_CONNECT=${TIMEOUT_CONNECT:-10s}
- TIMEOUT_CLIENT=${TIMEOUT_CLIENT:-30s}
- TIMEOUT_SERVER=${TIMEOUT_SERVER:-30s}
- EX_APPS_NET=${EX_APPS_NET:-ipv4@localhost}
- EX_APPS_COUNT=${EX_APPS_COUNT:-50}

appapi-dsp-https:
image: ghcr.io/cloud-py-api/nextcloud-appapi-dsp:release
container_name: nextcloud-appapi-dsp-https
network_mode: ${NETWORK_MODE:-host}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${CERT_PATH:-./data/ssl/app_api/app_api.pem}:/certs/cert.pem
environment:
- NC_HAPROXY_PASSWORD=${NC_HAPROXY_PASSWORD:-some_secure_password}
- BIND_ADDRESS=${BIND_ADDRESS:-172.17.0.1}
- HAPROXY_PORT=${HAPROXY_PORT:-2375}
- TIMEOUT_CONNECT=${TIMEOUT_CONNECT:-10s}
- TIMEOUT_CLIENT=${TIMEOUT_CLIENT:-30s}
- TIMEOUT_SERVER=${TIMEOUT_SERVER:-30s}
- EX_APPS_NET=${EX_APPS_NET:-ipv4@localhost}
- EX_APPS_COUNT=${EX_APPS_COUNT:-50}


volumes:
data:
config:
Expand Down
87 changes: 87 additions & 0 deletions docs/services/app_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# AppAPI

For [AppAPI](https://github.com/cloud-py-api/app_api) the [Docker Socket Proxy](https://github.com/cloud-py-api/docker-socket-proxy) (DSP) is required to work.

## HTTP AppAPI DSP
Copy link
Owner

Choose a reason for hiding this comment

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

Can you also clarify when to sue http vs https? Just depending on if nextcloud is using one or the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Locally for development it should be enough to use HTTP, HTTPS option in DSP is for remote install, locally could be used just for testing. In both cases ExApps are using HTTP to communicate to Nextcloud because of self-signed certs.


### 1. Start the HTTP DSP container

```bash
docker compose up -d appapi-dsp
```

### 2. Configure Deploy daemon

After the DSP container is running, configure the Deploy daemon in AppAPI admin settings with the following parameters:
Copy link
Owner

Choose a reason for hiding this comment

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

Can we also document which repo to clone for the app api settings to be available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but AppAPI is likely to be moved to server's core soon, so there will be no need to clone and build js, and now it's possible to just install AppAPI from AppStore, if you don't need the latest version from sources.


- **Host**: `http://nextcloud-appapi-dsp-http:2375`
- **Nextcloud URL**: `http://nextcloud.local` (locally always use http)
- **Enable https**: `false`
- **Network**: `master_default` (the network of nextcloud-docker-dev docker-compose, by default it is `master_default`)
- **HaProxy password**: `some_secure_password`

or via OCC CLI:

```bash
./scripts/occ.sh nextcloud -- app_api:daemon:register dsp_http "DSP HTTP" docker-install http "http://nextcloud.local" --net=master_default --set-default
```

## HTTPS AppAPI DSP

For HTTPS DSP setup, please refer to the [HTTPS (remote)](https://github.com/cloud-py-api/docker-socket-proxy?tab=readme-ov-file#httpsremote) section.

### 1. Generate self-signed certificates

Following the instruction from the DSP repository, generate and place the self-signed certificate in the `nextcloud-docker-dev/data/ssl/app_api/app_api.pem` directory.

> **Note**: Additionally, you can copy the `app_api.pem` file to the `nextcloud-docker-dev/data/shared` directory
> to be able to access it for import in each nextcloud dev container (e.g. `occ security:certificates:import /shared/app_api.pem`).

### 2. Start the HTTPS DSP container

```bash
docker compose up -d appapi-dsp-https
```

### 3. Configure Deploy daemon

After the DSP container is running and the certificate is imported in Nextcloud, configure the Deploy daemon in AppAPI admin settings with the following parameters:

- **Host**: `https://<nextcloud-appapi-dsp-https or BIND_ADDRESS IP>:2375` (use host depending on your setup)
- **Nextcloud URL**: `http://nextcloud.local` (locally always use http)
- **Enable https**: `true`
- **Network**: `host` (with https enabled, the network is forced to `host`)
- **HaProxy password**: `some_secure_password`
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a way to auto configure this using occ?

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, there is an occ command available to register Deploy daemon (occ app_api:daemon:register)


or via OCC CLI:

```bash
./scripts/occ.sh nextcloud -- app_api:daemon:register dsp_https "DSP HTTPS" docker-install https "http://nextcloud.local" --net=host --set-default
```


## Environment variables

The list of available environment variables for the AppAPI DSP is listed in its repository,
and in the `example.env` file.

## Troubleshooting

### Image of AppAPI DSP is not accessible

In case the AppAPI DSP image is not accessible, you can build it locally by cloning the [Docker Socket Proxy](https://github.com/cloud-py-api/docker-socket-proxy) repository and running the following commands:

```bash
git clone https://github.com/cloud-py-api/docker-socket-proxy.git
```

```bash
cd docker-socket-proxy
```

```bash
docker build -f ./Dockerfile -t nextcloud-appapi-dsp:latest ./
```

After that change the image name in the `docker-compose.yml` file
for `appapi-dsp` or `appapi-dsp-https` service to `nextcloud-appapi-dsp:latest` and try again.
14 changes: 14 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ SQL=mysql
# The mode of the xdebuger extention. This can be a comma separated list of
# the entries none, develop, debug, trace, and profile.
PHP_XDEBUG_MODE=develop

# Nextcloud AppAPI Docker Socket Proxy
# ------------------------------------
# NC_HAPROXY_PASSWORD=some_secure_password
# BIND_ADDRESS=172.17.0.1
# CERT_PATH=./data/ssl/app_api/app_api.pem
# NETWORK_MODE=host
# HAPROXY_PORT=2375
# TIMEOUT_CONNECT=10s
# TIMEOUT_CLIENT=30s
# TIMEOUT_SERVER=30s
# EX_APPS_NET=ipv4@localhost
# EX_APPS_COUNT=50
# ------------------------------------
Loading