senaite.docker/README.md

195 lines
6.2 KiB
Markdown
Raw Normal View History

2019-08-05 22:25:45 +08:00
# SENAITE Docker
[SENAITE](https://www.senaite.com) is a free and open source LIMS built on top of
[Plone](https://plone.org) and the [Zope application server](https://www.zope.org).
This repository is based [plone.docker](https://github.com/plone/plone.docker)
2019-10-31 19:32:15 +08:00
Thanks to the great work of http://github.com/avoinea and the other contributors.
2019-08-05 22:25:45 +08:00
### Try SENAITE
Click the _Try in PWD_ button below to get 4 hours to try SENAITE LIMS:
NOTE: A [DockerHub](https://hub.docker.com/) account is needed.
**Authentication: `admin:admin`**
[![Try in PWD](https://cdn.rawgit.com/play-with-docker/stacks/cff22438/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/senaite/senaite.docker/master/stack.yml)
## Usage
2019-08-05 22:31:37 +08:00
Choose either single SENAITE instance or ZEO cluster.
2019-08-05 22:25:45 +08:00
**It is inadvisable to use following configurations for production.**
### Standalone SENAITE Instance
Standalone instances are best suited for testing SENAITE and development.
Build and start the latest SENAITE container, based on [Debian](https://www.debian.org/).
2019-08-05 22:25:45 +08:00
```bash
2020-01-21 21:58:09 +08:00
$ git clone https://github.com/senaite/senaite.docker
2022-01-05 22:24:28 +08:00
$ cd senaite.docker/2.1.0
$ docker build -t senaite .
$ docker run --rm --name senaite -p 8080:8080 senaite
2019-08-05 22:25:45 +08:00
```
This image exposes the TCP Port `8080` via `EXPOSE 8080`, so standard container
linking will make it automatically available to the linked containers.
Now you can add a SENAITE Site at http://localhost:8080 - default user and
password are **`admin/admin`**.
### ZEO Cluster
ZEO cluster are best suited for production setups, you will **need** a loadbalancer.
Start ZEO server in the background
```bash
2019-08-05 22:31:37 +08:00
$ docker run -d --name=zeo senaite zeo
2019-08-05 22:25:45 +08:00
```
Start 2 SENAITE clients (also in the background)
```bash
2019-08-05 22:25:45 +08:00
$ docker run -d --name=instance1 --link=zeo -e ZEO_ADDRESS=zeo:8080 -p 8081:8080 senaite
$ docker run -d --name=instance2 --link=zeo -e ZEO_ADDRESS=zeo:8080 -p 8082:8080 senaite
```
### Start SENAITE In Debug Mode
2019-08-05 22:31:37 +08:00
You can also start SENAITE in debug mode (`fg`) by running
2019-08-05 22:25:45 +08:00
```bash
2019-08-05 22:25:45 +08:00
$ docker run -p 8080:8080 senaite fg
```
Debug mode may also be used with ZEO
```bash
2019-08-05 22:25:45 +08:00
$ docker run --link=zeo -e ZEO_ADDRESS=zeo:8080 -p 8080:8080 senaite fg
```
2019-08-05 22:31:37 +08:00
For more information on how to extend this image with your own custom settings,
adding more add-ons, building it or mounting volumes, please refer to the
[plone.docker documentation](https://docs.plone.org/manage/docker/docs/index.html).
2019-08-05 22:25:45 +08:00
## Supported Environment Variables
2019-08-05 22:31:37 +08:00
The SENAITE image uses several environment variable that allow to specify a more specific setup.
2019-08-05 22:25:45 +08:00
### For Basic Usage
* `ADDONS` - Customize SENAITE via Plone add-ons using this environment variable
* `ZEO_ADDRESS` - This environment variable allows you to run Plone image as a ZEO client.
2019-08-05 22:31:37 +08:00
Run SENAITE with ZEO and install the addon [senaite.storage](https://github.com/senaite/senaite.storage)
2019-08-05 22:25:45 +08:00
```bash
2019-08-05 22:25:45 +08:00
$ docker run --name=instance1 --link=zeo -e ZEO_ADDRESS=zeo:8080 -p 8080:8080 \
2019-08-05 22:31:37 +08:00
-e ADDONS="senaite.storage" senaite
2019-08-05 22:25:45 +08:00
```
To use specific add-ons versions:
```bash
2019-08-05 22:31:37 +08:00
-e ADDONS="senaite.storage==1.0.0"
2019-08-05 22:25:45 +08:00
```
### For Advanced Usage
* `PLONE_ZCML`, `ZCML` - Include custom Plone add-ons ZCML files (former `BUILDOUT_ZCML`)
* `PLONE_DEVELOP`, `DEVELOP` - Develop new or existing Plone add-ons (former `BUILDOUT_DEVELOP`)
* `ZEO_READ_ONLY` - Run Plone as a read-only ZEO client. Defaults to `off`.
* `ZEO_CLIENT_READ_ONLY_FALLBACK` - A flag indicating whether a read-only remote storage should be acceptable as a fallback when no writable storages are available. Defaults to `false`.
* `ZEO_SHARED_BLOB_DIR` - Set this to on if the ZEO server and the instance have access to the same directory. Defaults to `off`.
* `ZEO_STORAGE` - Set the storage number of the ZEO storage. Defaults to `1`.
* `ZEO_CLIENT_CACHE_SIZE` - Set the size of the ZEO client cache. Defaults to `128MB`.
* `ZEO_PACK_KEEP_OLD` - Can be set to false to disable the creation of *.fs.old files before the pack is run. Defaults to true.
2019-10-31 19:32:15 +08:00
2019-10-31 19:50:19 +08:00
## Development
The following sections describe how to create and publish a new senaite docker
image on docker hub.
### Create a new version of a docker image
2019-10-31 19:32:15 +08:00
Copy an existing version structure:
```console
2022-01-05 22:24:28 +08:00
$ cp -r 2.0.0 2.1.0
$ cd 2.1.0
$ docker build --tag=senaite:v2.1.0 .
2019-10-31 19:32:15 +08:00
[...]
Successfully built 7af3395db8f6
2022-01-05 22:24:28 +08:00
Successfully tagged senaite:v2.1.0
2019-10-31 19:32:15 +08:00
```
2022-01-05 22:24:28 +08:00
Note that the the image will automatically tagged as `v2.1.0`.
2019-10-31 19:32:15 +08:00
2019-10-31 19:50:19 +08:00
### Run the container
2019-10-31 19:32:15 +08:00
Start a container based on your new image:
```
2022-01-05 22:24:28 +08:00
docker container run --publish 9999:8080 --detach --name s210 senaite:v2.1.0
2019-10-31 19:32:15 +08:00
```
We used a couple of common flags here:
- `--publish` asks Docker to forward traffic incoming on the hosts port
9999, to the containers port 8080 (containers have their own
private set of ports, so if we want to reach one from the
network, we have to forward traffic to it in this way;
otherwise, firewall rules will prevent all network traffic from
reaching your container, as a default security posture).
- `--detach` asks Docker to run this container in the background.
- `--name` lets us specify a name with which we can refer to our container in
subset
```
2019-10-31 19:50:19 +08:00
2019-10-31 19:32:15 +08:00
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2022-01-05 22:24:28 +08:00
ecf514d717ba senaite:v2.1.0 "/docker-entrypoint.…" 26 seconds ago Up 24 seconds (health: starting) 0.0.0.0:9999->8080/tcp s210
2019-10-31 19:32:15 +08:00
```
Go to http://localhost:9999 to install senaite.
2022-01-05 22:24:28 +08:00
Stop the container with `docker container stop s210`.
2019-10-31 19:32:15 +08:00
2019-10-31 19:50:19 +08:00
### Publish the container on Docker Hub
Images must be namespaced correctly to share on Docker Hub. Specifically, images
must be named like `<Docker Hub ID>/<Repository Name>:<tag>.` We can relabel our
2022-01-05 22:24:28 +08:00
`senaite:2.1.0` image like this:
2019-10-31 19:50:19 +08:00
```console
2022-01-05 22:24:28 +08:00
$ docker image tag senaite:v2.1.0 ramonski/senaite:v2.1.0
$ docker image tag senaite:v2.1.0 ramonski/senaite:latest
2019-10-31 19:50:19 +08:00
```
Finally, push the image to Docker Hub:
```console
2022-01-05 22:24:28 +08:00
docker image push ramonski/senaite:v2.1.0
2019-10-31 19:50:19 +08:00
docker image push ramonski/senaite:latest
```
### Further information
2019-10-31 19:32:15 +08:00
Please refer to this documentation for further information:
2019-10-31 19:50:19 +08:00
2019-10-31 19:32:15 +08:00
https://docs.docker.com/get-started