无法在云上使用 gcsfuse 安装存储桶 运行
Unable to mount bucket with gcsfuse on Cloud Run
借助 Google Cloud 运行 的第二代运行时,现在可以使用 gcsfuse 装载 Google 个存储桶。
https://cloud.google.com/run/docs/tutorials/network-filesystems-fuse
python3 示例运行良好。不幸的是,我的 Dockerfile 不断收到此错误:
bin/fusermount: failed to open /dev/fuse: Permission denied
mountWithArgs: mountWithConn: Mount: mount: running /bin/fusermount: exit status 1
Docker 文件
# https://github.com/chiaen/docker-gcsfuse
FROM golang:1.17.5-alpine as gcsfuse
RUN apk add --no-cache git
ENV GOPATH /go
RUN go get -u github.com/googlecloudplatform/gcsfuse
FROM composer:2 as vendor
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install --ignore-platform-reqs --no-interaction --prefer-dist
FROM craftcms/nginx:7.4
ENV MNT_DIR /mnt/gcs
USER root
RUN apk add --no-cache mysql-client postgresql-client ca-certificates fuse nano sudo tini bash
RUN mkdir -p $MNT_DIR
RUN chown www-data:www-data $MNT_DIR
USER www-data
COPY --chown=www-data:www-data --from=vendor /app/vendor/ /app/vendor/
COPY --chown=www-data:www-data . .
COPY --from=gcsfuse /go/bin/gcsfuse /usr/local/bin
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
由于有几个文件,我把所有的文件都放在一个github repo 中。
https://github.com/internetztube/cloud-run-persistent-storage-issue
更新:
我解决了 在 Cloud 运行 中安装 GCS 桶 运行 和 read/write 对象具有以下更改:
- Dockerfile:
# https://github.com/chiaen/docker-gcsfuse
FROM golang:1.17.5-alpine as gcsfuse
RUN apk add --no-cache git
ENV GOPATH /go
RUN go get -u github.com/googlecloudplatform/gcsfuse
FROM composer:2 as vendor
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install --ignore-platform-reqs --no-interaction --prefer-dist
FROM craftcms/nginx:7.4
ENV MNT_DIR /mnt/gcs
USER root
RUN apk add --no-cache mysql-client postgresql-client ca-certificates fuse nano sudo tini bash
RUN mkdir -p $MNT_DIR
RUN chown www-data:www-data $MNT_DIR
COPY --chown=www-data:www-data --from=vendor /app/vendor/ /app/vendor/
COPY --chown=www-data:www-data . .
COPY --from=gcsfuse /go/bin/gcsfuse /usr/local/bin
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
- 在
gcsfuse.sh
中添加 -file-mode=777 -dir-mode=777
和 gcsfuse
命令以在 GCS 存储桶的安装目录中启用 read/write:
gcsfuse -o rw,allow_other -file-mode=777 -dir-mode=777 --foreground --debug_http --debug_gcs --debug_fuse --implicit-dirs $DISK_BUCKET $MNT_DIR
- 硬编码路径(
/mnt/gcs/demo.txt
而不是 ../storage/demo.txt
)以在文件 web/index.php
. 中进行测试
截图输出:
借助 Google Cloud 运行 的第二代运行时,现在可以使用 gcsfuse 装载 Google 个存储桶。
https://cloud.google.com/run/docs/tutorials/network-filesystems-fuse
python3 示例运行良好。不幸的是,我的 Dockerfile 不断收到此错误:
bin/fusermount: failed to open /dev/fuse: Permission denied
mountWithArgs: mountWithConn: Mount: mount: running /bin/fusermount: exit status 1
Docker 文件
# https://github.com/chiaen/docker-gcsfuse
FROM golang:1.17.5-alpine as gcsfuse
RUN apk add --no-cache git
ENV GOPATH /go
RUN go get -u github.com/googlecloudplatform/gcsfuse
FROM composer:2 as vendor
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install --ignore-platform-reqs --no-interaction --prefer-dist
FROM craftcms/nginx:7.4
ENV MNT_DIR /mnt/gcs
USER root
RUN apk add --no-cache mysql-client postgresql-client ca-certificates fuse nano sudo tini bash
RUN mkdir -p $MNT_DIR
RUN chown www-data:www-data $MNT_DIR
USER www-data
COPY --chown=www-data:www-data --from=vendor /app/vendor/ /app/vendor/
COPY --chown=www-data:www-data . .
COPY --from=gcsfuse /go/bin/gcsfuse /usr/local/bin
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
由于有几个文件,我把所有的文件都放在一个github repo 中。 https://github.com/internetztube/cloud-run-persistent-storage-issue
更新:
我解决了 在 Cloud 运行 中安装 GCS 桶 运行 和 read/write 对象具有以下更改:
- Dockerfile:
# https://github.com/chiaen/docker-gcsfuse
FROM golang:1.17.5-alpine as gcsfuse
RUN apk add --no-cache git
ENV GOPATH /go
RUN go get -u github.com/googlecloudplatform/gcsfuse
FROM composer:2 as vendor
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install --ignore-platform-reqs --no-interaction --prefer-dist
FROM craftcms/nginx:7.4
ENV MNT_DIR /mnt/gcs
USER root
RUN apk add --no-cache mysql-client postgresql-client ca-certificates fuse nano sudo tini bash
RUN mkdir -p $MNT_DIR
RUN chown www-data:www-data $MNT_DIR
COPY --chown=www-data:www-data --from=vendor /app/vendor/ /app/vendor/
COPY --chown=www-data:www-data . .
COPY --from=gcsfuse /go/bin/gcsfuse /usr/local/bin
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
- 在
gcsfuse.sh
中添加-file-mode=777 -dir-mode=777
和gcsfuse
命令以在 GCS 存储桶的安装目录中启用 read/write:
gcsfuse -o rw,allow_other -file-mode=777 -dir-mode=777 --foreground --debug_http --debug_gcs --debug_fuse --implicit-dirs $DISK_BUCKET $MNT_DIR
- 硬编码路径(
/mnt/gcs/demo.txt
而不是../storage/demo.txt
)以在文件web/index.php
. 中进行测试
截图输出: