This repository contains a Dockerfile to spin up an exemplary HTTP/REST server following the Specification of the AAS Part 2 API with ease. The server currently implements the following interfaces:
It uses the HTTP API and the AASX, JSON, and XML Adapters of the BaSyx Python SDK, to serve regarding files from a given directory. The files are only read, chages won't persist.
Alternatively, the container can also be told to use the Local-File Backend instead, which stores AAS and Submodels as individual JSON files and allows for persistent changes (except supplementary files, i.e. files referenced by File
submodel elements).
See below on how to configure this.
The container image can be built via:
$ docker buildx build -t basyx-python-sdk-http-server .
The container needs to be provided with the directory /storage
to store AAS and Submodel files: AASX, JSON, XML or JSON files of Local-File Backend.
This directory can be mapped via the -v
option from another image or a local directory.
To map the directory storage
inside the container, -v ./storage:/storage
can be used.
The directory storage
will be created in the current working directory, if it doesn't already exist.
The HTTP server inside the container listens on port 80 by default.
To expose it on the host on port 8080, use the option -p 8080:80
when running it.
The container can be configured via environment variables:
API_BASE_PATH
determines the base path under which all other API paths are made available. Default:/api/v3.0
STORAGE_TYPE
can be one ofLOCAL_FILE_READ_ONLY
orLOCAL_FILE_BACKEND
:- When set to
LOCAL_FILE_READ_ONLY
(the default), the server will read and serve AASX, JSON, XML files from the storage directory. The files are not modified, all changes done via the API are only stored in memory. - When instead set to
LOCAL_FILE
, the server makes use of the LocalFileBackend, where AAS and Submodels are persistently stored as JSON files. Supplementary files, i.e. files referenced byFile
submodel elements, are not stored in this case.
- When set to
STORAGE_PATH
sets the directory to read the files from within the container. If you bind your files to a directory different from the default/storage
, you can use this variable to adjust the server accordingly.
Putting it all together, the container can be started via the following command:
$ docker run -p 8080:80 -v ./storage:/storage basyx-python-sdk-http-server
Since Windows uses backslashes instead of forward slashes in paths, you'll have to adjust the path to the storage directory there:
> docker run -p 8080:80 -v .\storage:/storage basyx-python-sdk-http-server
Per default, the server will use the LOCAL_FILE_READ_ONLY
storage type and serve the API under /api/v3.0
and read files from /storage
. If you want to change this, you can do so like this:
$ docker run -p 8080:80 -v ./storage2:/storage2 -e API_BASE_PATH=/api/v3.1 -e STORAGE_TYPE=LOCAL_FILE_BACKEND -e STORAGE_PATH=/storage2 basyx-python-sdk-http-server
This Dockerfile is inspired by the tiangolo/uwsgi-nginx-docker repository.