Skip to content

Commit

Permalink
docs: Add documentation for setting up local MinIO installation (Huma…
Browse files Browse the repository at this point in the history
…nSignal#3945)

Co-authored-by: Sergey Zhuk <[email protected]>
  • Loading branch information
Gornoka and farioas authored May 3, 2023
1 parent 12f4621 commit 1673802
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 15 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ To start using the app from `http://localhost` run this command:
docker-compose up
```

### Run with Docker Compose + MinIO
You can also run it with an additional MinIO server for local S3 storage. This is particularly useful when you want to
test the behavior with S3 storage on your local system. To start Label Studio in this way, you need to run the following command:
````bash
# Add sudo on Linux if you are not a member of the docker group
docker compose -f docker-compose.yml -f docker-compose.minio.yml up -d
````
If you do not have a static IP address, you must create an entry in your hosts file so that both Label Studio and your
browser can access the MinIO server. For more detailed instructions, please refer to [our guide on storing data](docs/source/guide/storedata.md).


### Install locally with pip

```bash
Expand Down
44 changes: 44 additions & 0 deletions docker-compose.minio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3.9"

# rotating logs so they do not overflow
x-logging:
logging: &default-logging
driver: "local"
options:
max-size: "10m"
max-file: "3"

services:
# not replicated setup for test setup, use a proper aws S3 compatible cluster in production
minio:
image: quay.io/minio/minio:RELEASE.2023-03-13T19-46-17Z
command: server /data --console-address ":9009"
restart: unless-stopped
logging: *default-logging
ports:
- "9000:9000"
- "9009:9009"
volumes:
- minio-data:/data
# configure env vars in .env file or your systems environment
environment:
- MINIO_ROOT_USER=${MINIO_ROOT_USER:-minio_admin_do_not_use_in_production}
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-minio_admin_do_not_use_in_production}
- MINIO_PROMETHEUS_URL=${MINIO_PROMETHEUS_URL:-http://prometheus:9090}
- MINIO_PROMETHEUS_AUTH_TYPE=${MINIO_PROMETHEUS_AUTH_TYPE:-public}
prometheus:
image: quay.io/prometheus/prometheus:v2.37.1
restart: unless-stopped
logging: *default-logging
# ports:
# - "9090:9090"
volumes:
- "./prometheus/minio/prometheus.yml:/etc/prometheus/prometheus.yml"
- "prometheus-data:/prometheus"
command:
- "--config.file=/etc/prometheus/prometheus.yml"
volumes:
minio-data:
prometheus-data:


29 changes: 14 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
version: "3.9"

services:
nginx:
build: .
image: heartexlabs/label-studio:latest
restart: unless-stopped
ports:
- "8080:8085"
- "8081:8086"
depends_on:
- app
environment:
- LABEL_STUDIO_HOST=${LABEL_STUDIO_HOST:-}
# Optional: Specify SSL termination certificate & key
# Just drop your cert.pem and cert.key into folder 'deploy/nginx/certs'
# - NGINX_SSL_CERT=/certs/cert.pem
# - NGINX_SSL_CERT_KEY=/certs/cert.key
# Optional: Specify SSL termination certificate & key
# Just drop your cert.pem and cert.key into folder 'deploy/nginx/certs'
# - NGINX_SSL_CERT=/certs/cert.pem
# - NGINX_SSL_CERT_KEY=/certs/cert.key
volumes:
- ./mydata:/label-studio/data:rw
- ./deploy/nginx/certs:/certs:ro
# Optional: Override nginx default conf
# - ./deploy/nginx/default.conf:/label-studio/deploy/nginx/default.conf
# Optional: Override nginx default conf
# - ./deploy/nginx/default.conf:/label-studio/deploy/nginx/default.conf
command: nginx

app:
stdin_open: true
tty: true
build: .
image: heartexlabs/label-studio:latest
restart: unless-stopped
expose:
- "8000"
depends_on:
Expand All @@ -40,27 +41,25 @@ services:
- POSTGRE_HOST=db
- LABEL_STUDIO_HOST=${LABEL_STUDIO_HOST:-}
- JSON_LOG=1
# - LOG_LEVEL=DEBUG
# - LOG_LEVEL=DEBUG
volumes:
- ./mydata:/label-studio/data:rw
command: label-studio-uwsgi

db:
image: postgres:11.5
hostname: db
restart: always
restart: unless-stopped
# Optional: Enable TLS on PostgreSQL
# Just drop your server.crt and server.key into folder 'deploy/pgsql/certs'
# NOTE: Both files must have permissions u=rw (0600) or less
# command: >
# -c ssl=on
# -c ssl_cert_file=/var/lib/postgresql/certs/server.crt
# -c ssl_key_file=/var/lib/postgresql/certs/server.key
# command: >
# -c ssl=on
# -c ssl_cert_file=/var/lib/postgresql/certs/server.crt
# -c ssl_key_file=/var/lib/postgresql/certs/server.key
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- ${POSTGRES_DATA_DIR:-./postgres-data}:/var/lib/postgresql/data
- ./deploy/pgsql/certs:/var/lib/postgresql/certs:ro

volumes:
static: {}
44 changes: 44 additions & 0 deletions docs/source/guide/storedata.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,50 @@ When you start Label Studio using Docker Compose, you start it using a PostgreSQ
docker-compose up -d
```

## Minio Blob Storage
MinIO is a blob storage solution that is compatible with Amazon S3. You can use MinIO to store your labeling tasks.

### Starting the containers
For local development, you can host a local MinIO server to emulate an S3-based production environment more closely.
An example docker-compose file for this is available in the [Label Studio repository](https://github.com/heartexlabs/label-studio).

To run MinIO alongside your Label Studio instance, use the following command:
````bash
# Add sudo on Linux if you are not a member of the docker group
docker compose -f docker-compose.yml -f docker-compose.minio.yml up -d
````
The MinIO server will be accessible at http://localhost:9000.
To configure MinIO settings, create a `.env` file. Remember to override the default credentials.

````.dotenv
MINIO_ROOT_USER=minio_admin_do_not_use_in_production
MINIO_ROOT_PASSWORD=minio_admin_do_not_use_in_production
````

### Connect Label Studio to local MinIO

If you do not have a static IP address, create an entry in your hosts file so that both the Label Studio container and
your browser can find MinIO at the same hostname.

The following entry redirects all requests to MinIO to your local system:
```text
127.0.0.1 minio
```

On Windows, you can find your hosts file at `C:\Windows\System32\drivers\etc\hosts`.
On Linux, you can find your hosts file at `/etc/hosts`.
On macOS, you can find your hosts file at `/private/etc/hosts`.

After modifying your hosts file, you can connect to your MinIO server with your browser at http://minio:9000.

### Remove MinIO data
You can remove your MinIO installation by removing the containers and the associated volumes.
This operation is destructive and will remove all data stored in MinIO.
```bash
docker-compose -f docker-compose.minio.yml down --volumes
````


## Data persistence

If you're using a Docker container, Heroku, or another cloud provider, you might want your data to persist after shutting down Label Studio. You can [export your data](export.html) to persist your labeling task data and annotations, but to preserve the state of Label Studio and assets such as files that you uploaded for labeling, set up data persistence.
Expand Down
6 changes: 6 additions & 0 deletions prometheus/minio/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
scrape_configs:
- job_name: minio-job
metrics_path: /minio/v2/metrics/cluster
scheme: http
static_configs:
- targets: ['minio:9000']

0 comments on commit 1673802

Please sign in to comment.