diff --git a/devices/linux-client/Dockerfile.demo-client b/devices/linux-client/Dockerfile.demo-client new file mode 100644 index 0000000..64d756b --- /dev/null +++ b/devices/linux-client/Dockerfile.demo-client @@ -0,0 +1,9 @@ +FROM antmicro/rdfm-client-builder:latest + +# Copy all sources +COPY . /rdfm-client/ +WORKDIR /rdfm-client/ +# Install the RDFM client +RUN make install + +CMD [ "/rdfm-client/scripts/test-docker/docker-entrypoint.sh" ] \ No newline at end of file diff --git a/devices/linux-client/Makefile b/devices/linux-client/Makefile index c24ab50..0c87fb4 100644 --- a/devices/linux-client/Makefile +++ b/devices/linux-client/Makefile @@ -24,6 +24,9 @@ VERSION = $(shell git describe --tags --dirty --exact-match 2>/dev/null || git r GO_LDFLAGS = \ -ldflags "-X github.com/antmicro/rdfm/conf.Version=$(VERSION)" +BUILDER_IMAGE_TAG = antmicro/rdfm-client-builder:latest +DEMO_CLIENT_TAG = antmicro/rdfm-linux-demo-client:latest + ifeq ($(V),1) BUILDV = -v endif @@ -42,6 +45,12 @@ build: rdfm: build +docker-builder: + docker build -f Dockerfile -t $(BUILDER_IMAGE_TAG) . + +docker-demo-client: docker-builder + docker build -f Dockerfile.demo-client -t $(DEMO_CLIENT_TAG) . + install: install-bin \ install-conf @@ -72,6 +81,8 @@ test: $(GO) test $(BUILDV) $(PKGS) .PHONY: build +.PHONY: docker-builder +.PHONY: docker-demo-client .PHONY: clean .PHONY: test .PHONY: install diff --git a/devices/linux-client/docker-compose.demo.yml b/devices/linux-client/docker-compose.demo.yml new file mode 100644 index 0000000..1298413 --- /dev/null +++ b/devices/linux-client/docker-compose.demo.yml @@ -0,0 +1,22 @@ +version: '3' + +services: + demo-client: + image: antmicro/rdfm-linux-demo-client:latest + network_mode: host + restart: unless-stopped + environment: + # Device type reported to the server + RDFM_CLIENT_DEVTYPE: x86_64 + # Example: plain HTTP server connection + RDFM_CLIENT_SERVER_URL: http://127.0.0.1:5000/ + # Example: HTTPS server connection + # Remember to update the URL to use HTTPS! + # RDFM_CLIENT_SERVER_URL: https://127.0.0.1:5000/ + # RDFM_CLIENT_SERVER_CERT: /var/lib/rdfm/CA.crt + volumes: + # Simulate a persistent "partition" for the configuration + - data:/var/lib/rdfm/ + +volumes: + data: diff --git a/devices/linux-client/scripts/test-docker/docker-entrypoint.sh b/devices/linux-client/scripts/test-docker/docker-entrypoint.sh new file mode 100755 index 0000000..1d41fd0 --- /dev/null +++ b/devices/linux-client/scripts/test-docker/docker-entrypoint.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -e + +# This is the entrypoint for the Dockerized demo client +# This can be used to test basic integration with the RDFM server + +# Environment variable overrides +SERVER_URL="${RDFM_CLIENT_SERVER_URL:-http://127.0.0.1:5000/}" +SERVER_CERT="${RDFM_CLIENT_SERVER_CERT:-/dev/zero}" +PART_A="${RDFM_CLIENT_PART_A:-/dev/zero}" +PART_B="${RDFM_CLIENT_PART_B:-/dev/zero}" +DEVICE_TYPE="${RDFM_CLIENT_DEVTYPE:-x86_64}" + +# Generate a valid configuration +cat >/etc/rdfm/artifact_info << EOF +artifact_name=unknown +EOF + +cat >/var/lib/rdfm/device_type << EOF +device_type=${DEVICE_TYPE} +EOF + +cat >/etc/rdfm/rdfm.conf << EOF +{ + "RootfsPartA": "${PART_A}", + "RootfsPartB": "${PART_B}" +} +EOF + +cat >/var/lib/rdfm/rdfm.conf <> /etc/hosts + +# Start daemonized RDFM device client +exec rdfm daemonize ${CLIENT_ARGS} diff --git a/documentation/source/rdfm_linux_device_client.md b/documentation/source/rdfm_linux_device_client.md index 8833c10..c5b1d3e 100644 --- a/documentation/source/rdfm_linux_device_client.md +++ b/documentation/source/rdfm_linux_device_client.md @@ -55,6 +55,32 @@ cd data/devices/linux-client make ``` +## Testing server-device integration with a demo Linux device client + +For development purposes, it's often necessary to test server integration with an existing device client. +To do this, it is possible to use the [RDFM Linux device client](rdfm_linux_device_client.md), without having to build a compatible system image utilizing the Yocto [meta-rdfm layer](https://github.com/antmicro/meta-antmicro/tree/master/meta-rdfm). +First, build the demo container image: + +``` +cd devices/linux-client/ +make docker-demo-client +``` + +You can then start a demo Linux client by running the following: +``` +docker-compose -f docker-compose.demo.yml up +``` + +If required, the following environment variables can be changed in the above `docker-compose.demo.yml` file: + +- `RDFM_CLIENT_SERVER_URL` - URL to the RDFM Management Server, defaults to `http://127.0.0.1:5000/`. +- `RDFM_CLIENT_SERVER_CERT` **(optional)** - path (within the container) to the CA certificate to use for verification of the connection to the RDFM server. When this variable is set, the server URL must also be updated to use HTTPS instead of HTTP. +- `RDFM_CLIENT_DEVTYPE` - device type that will be advertised to the RDFM server; used for determining package compatibility, defaults to `x86_64`. +- `RDFM_CLIENT_PART_A`, `RDFM_CLIENT_PART_B` **(optional)** - specifies path (within the container) to the rootfs A/B partitions that updates will be installed to. They do not need to be specified for basic integration testing; any updates that are installed will go to `/dev/zero` by default. + +The demo client will automatically connect to the specified RDFM server and fetch any available packages. +To manage the device and update deployment, you can use the [RDFM Manager utility](rdfm_manager.md). + ## Developer Guide ### Running tests