diff --git a/docker/layotto-minio/config_minio.json b/docker/layotto-minio/config_minio.json new file mode 100644 index 0000000000..c48302521b --- /dev/null +++ b/docker/layotto-minio/config_minio.json @@ -0,0 +1,53 @@ +{ + "servers": [ + { + "default_log_path": "stdout", + "default_log_level": "DEBUG", + "listeners": [ + { + "name": "grpc", + "address": "0.0.0.0:34904", + "bind_port": true, + "filter_chains": [ + { + "filters": [ + { + "type": "grpc", + "config": { + "server_name": "runtime", + "grpc_config": { + "hellos": { + "quick_start_demo": { + "type": "helloworld", + "hello": "greeting" + } + }, + "file": { + "file_demo": { + "type": "minioOSS", + "metadata": [ + { + "endpoint": "minio:9000", + "accessKeyID": "layotto", + "accessKeySecret": "layotto_secret", + "SSL":false, + "region":"us-east-1" + } + ] + } + } + } + } + } + ] + } + ] + } + ] + } + ], + "pprof": { + "debug": true, + "port_value": 34902 + } + } \ No newline at end of file diff --git a/docker/layotto-minio/docker-compose.yml b/docker/layotto-minio/docker-compose.yml new file mode 100644 index 0000000000..f8ab97dbc9 --- /dev/null +++ b/docker/layotto-minio/docker-compose.yml @@ -0,0 +1,44 @@ +#Licensed to the Apache Software Foundation (ASF) under one or more +#contributor license agreements. See the NOTICE file distributed with +#this work for additional information regarding copyright ownership. +#The ASF licenses this file to You under the Apache License, Version 2.0 +#(the "License"); you may not use this file except in compliance with +#the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +#Unless required by applicable law or agreed to in writing, software +#distributed under the License is distributed on an "AS IS" BASIS, +#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +#See the License for the specific language governing permissions and +#limitations under the License. + +version: '3.3' +services: + layotto: + image: layotto/layotto:latest + container_name: layotto + command: + - 'start' + volumes: + - ./config_minio.json:/runtime/configs/config.json + ports: + - 34904:34904 + - 34903:34903 + - 34902:34902 + - 34999:34999 + depends_on: + - minio + + minio: + image: minio/minio + container_name: minio + environment: + MINIO_ROOT_USER: layotto + MINIO_ROOT_PASSWORD: layotto_secret + command: server /data --console-address ':9090' + ports: + - 9000:9000 + - 9090:9090 + privileged: true + restart: always \ No newline at end of file diff --git a/docs/zh/start/file/minio.md b/docs/zh/start/file/minio.md index 76a8e23623..f62c93fa20 100644 --- a/docs/zh/start/file/minio.md +++ b/docs/zh/start/file/minio.md @@ -4,7 +4,23 @@ Layotto提供了访问文件的示例 [demo](https://github.com/mosn/layotto/blob/main/demo/file/client.go) ,该示例实现了文件的增删改查操作。 -### 第一步:启动 MinIO 服务 +### step 1. 启动 MinIO 和 Layotto + +#### **使用 Docker Compose** +您可以使用 docker-compose 启动 MinIO 和 Layotto + +```bash +cd docker/layotto-minio +# Start MinIO and layotto with docker-compose +docker-compose up -d +``` + +#### **本地编译(不适合 Windows)** +您可以使用 Docker 运行 MinIO,然后本地编译、运行 Layotto。 + +> [!TIP|label: 不适合 Windows 用户] +> Layotto 在 Windows 下会编译失败。建议 Windows 用户使用 docker-compose 部署 +#### step 1.1. 启动 MinIO 服务 您可以使用 Docker 启动本地MinIO服务, 参考[官方文档](http://docs.minio.org.cn/docs/master/minio-docker-quickstart-guide) ```shell @@ -15,8 +31,7 @@ docker run -d -p 9000:9000 -p 9090:9090 --name minio \ minio/minio server /data --console-address ':9090' ``` - -### 第二步:启动layotto +#### step 1.2. 启动layotto layotto提供了minio的配置文件[oss配置](https://github.com/mosn/layotto/blob/main/configs/config_file.json) ,如下所示 @@ -56,8 +71,9 @@ go build -o layotto ```shell @background ./layotto start -c ../../configs/config_file.json ``` + -### 第三步:启动测试demo +### step 2. 启动测试demo Layotto提供了访问文件的示例 [demo](https://github.com/mosn/layotto/blob/main/demo/file/client.go) @@ -79,6 +95,23 @@ go build client.go ./client del test/hello/layotto.txt ``` +### step 3. 销毁容器,释放资源 + +#### **关闭 Docker Compose** +如果您是用 docker-compose 启动的 MinIO 和 Layotto,可以按以下方式关闭: + +```bash +cd ${project_path}/docker/layotto-minio +docker-compose stop +``` +#### **销毁 MinIO Docker 容器** +如果您是用 Docker 启动的 MinIO,可以按以下方式销毁 MinIO 容器: + +```shell +docker rm -f minio +``` + + #### 细节以后再说,继续体验其他API 通过左侧的导航栏,继续体验别的API吧!