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

chore: Docker compose init #116

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
73 changes: 73 additions & 0 deletions docker-compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# W&B Server Docker Compose README

This repository contains a Docker Compose configuration for setting up a W&B (Weights & Biases) server. This configuration includes various services necessary for the operation of the W&B server, including a database, cache, storage, and a system for updating the W&B server container.

Copy link
Contributor

Choose a reason for hiding this comment

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

README is nice!

## Services

1. `db` - A MySQL database used for storing W&B data.
2. `redis` - A Redis cache used by the W&B server.
3. `minio` - A MinIO server that acts as an S3-compatible storage for the W&B server.
4. `createbucket` - A service that sets up the MinIO bucket for the W&B server.
5. `wandb` - The W&B server itself.
6. `watchtower` - A service that automatically updates the W&B server container.

## Environment Variables

Some of the services use environment variables for configuration. These should be changed as per your requirements.

- `MYSQL_DATABASE`, `MYSQL_USER`, `MYSQL_PASSWORD`, and `MYSQL_ROOT_PASSWORD` are used for the MySQL database configuration.
- `MINIO_ROOT_USER` and `MINIO_ROOT_PASSWORD` are used for the MinIO server configuration.
- `WATCHTOWER_SCHEDULE`, `WATCHTOWER_CLEANUP`, `WATCHTOWER_DEBUG`, `WATCHTOWER_INCLUDE_RESTARTING`, and `WATCHTOWER_INCLUDE_STOPPED` are used for the Watchtower configuration.

## How to Run

Make sure Docker and Docker Compose are installed on your machine.

1. Clone this repository.

```
git clone <repo-url>
```

2. Navigate to the repository folder.

```
cd <repo-folder>
```

3. Run the Docker Compose configuration.

```
docker-compose up
```

## Ports

The following ports are used by the services:

- `db` - 3306
- `redis` - 6379
- `minio` - 9000, 9001
- `wandb` - 8080

## Healthchecks

Healthchecks are set up for the `db`, `redis`, and `minio` services. These are used to ensure that these services are running correctly.

## Volumes

Docker volumes are used for data persistence across container restarts. The following volumes are used:

- `db` - Used for storing MySQL database data.
- `redis` - Used for storing Redis cache data.
- `files` - Used for storing MinIO files.

## Networks

A Docker network named `wandb` is used for communication between the services.

## Autoupgrade

The `watchtower` service is set up to automatically upgrade the `wandb_server` container every Sunday. This can be adjusted as per your requirements.

Please note, this setup requires Docker and Docker Compose to run. If you need any further assistance, feel free to reach out or open an issue.
125 changes: 125 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
version: '3'

services:
db:
container_name: wandb_db
image: mysql:8.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we fully on 8.0? I know EOL is coming up, but can't remember where we are on this

restart: always
networks:
- wandb
environment:
MYSQL_DATABASE: 'wandb'
MYSQL_USER: 'wandb'
MYSQL_PASSWORD: 'wandb'
MYSQL_ROOT_PASSWORD: 'wandb'
ports:
- 3306:3306
volumes:
- db:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
interval: 5s
retries: 10

redis:
container_name: wandb_redis
image: redis:6
restart: always
networks:
- wandb
ports:
- 6379:6379
volumes:
- redis:/data
healthcheck:
interval: 5s
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]

minio:
container_name: wandb_storage
image: minio/minio
restart: always
networks:
- wandb
ports:
- 9000:9000
- 9001:9001
volumes:
- files:/data
environment:
MINIO_ROOT_USER: wandb
MINIO_ROOT_PASSWORD: wandbadmin
MINIO_REGION_NAME: us-east-1
command: server /data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 5s
timeout: 20s
retries: 5

createbucket:
container_name: wandb_createbucket
image: minio/mc
depends_on:
minio:
condition: service_healthy
restart: on-failure
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:9000 wandb wandbadmin;
/usr/bin/mc mb myminio/data;
/usr/bin/mc policy set public myminio/data;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to set the CORS policy here?

"
networks:
- wandb

wandb:
container_name: wandb_server
image: wandb/local:latest
restart: always
networks:
- wandb
links:
- db
- redis
- minio
ports:
- 8080:8080
environment:
MYSQL: mysql://wandb:wandb@db:3306/wandb
BUCKET_QUEUE: internal://
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want this to point to the redis instance

AWS_REGION: us-east-1
BUCKET: s3://wandb:wandbadmin@minio:9000/data
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
Copy link
Contributor

Choose a reason for hiding this comment

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

where is service_healthy defined?


watchtower:
container_name: wandb_autoupgrade
image: containrrr/watchtower
restart: always
environment:
WATCHTOWER_SCHEDULE: 0 0 0 * * 0 # Every sunday
WATCHTOWER_CLEANUP: "true"
WATCHTOWER_DEBUG: "true"
WATCHTOWER_INCLUDE_RESTARTING: "true"
WATCHTOWER_INCLUDE_STOPPED: "true"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: wandb_server

volumes:
db:
driver: local
redis:
driver: local
files:
driver: local

networks:
wandb: