From 16c704b8ab8424b775fb226a6abf02993b89d4b1 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Fri, 8 Nov 2024 11:21:50 +0100 Subject: [PATCH] Init commit --- Dockerfile | 31 +++++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ startup.sh | 17 +++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 startup.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5ecd4ad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM alpine:latest + +# metadata +LABEL org.opencontainers.image.source=https://github.com/kevinmidboe/s3-mounter +LABEL org.opencontainers.image.description="Mount s3 (google) bucket to folder using s3fs-fuse" +LABEL org.opencontainers.image.licenses=MIT + +ENV MNT_POINT=/var/s3fs +ARG S3FS_VERSION=v1.95 + +# install, compile and cleanup s3fs-fuse +RUN apk --update --no-cache add fuse alpine-sdk automake autoconf libxml2-dev fuse-dev curl-dev git bash; \ + git clone https://github.com/s3fs-fuse/s3fs-fuse.git; \ + cd s3fs-fuse; \ + ./autogen.sh; \ + ./configure; \ + make; \ + make install; \ + make clean; \ + rm -rf /var/cache/apk/*; \ + apk del git automake autoconf + +# setup mountpoint +RUN mkdir -p "$MNT_POINT" +WORKDIR "$MNT_POINT" + +# copy startup script +COPY startup.sh /app/startup.sh +RUN chmod 500 /app/startup.sh + +CMD /app/startup.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6f6325a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Kevin Midbøe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b2021bf --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# s3fs mounter + +Image for mounting s3 (google) bucket to filesystem. + +## build + +Build docker image. + +```bash +docker build -t s3fs-mounter . +``` + +## run + +Run docker image. Need to run with privileged flag. + +```bash +export S3_BUCKET=BUCKET_NAME +export HMAC_KEY=ACCESS_KEY:SECRET + +docker run --rm --privileged -e S3_BUCKET -e HMAC_KEY --name s3fs-mounter s3fs-mounter +``` diff --git a/startup.sh b/startup.sh new file mode 100644 index 0000000..2dcff91 --- /dev/null +++ b/startup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "$HMAC_KEY" > /etc/gcs-auth && chmod 600 /etc/gcs-auth +s3fs -d -d "$S3_BUCKET" "$MNT_POINT" \ + -o use_cache=/tmp \ + -o passwd_file=/etc/gcs-auth \ + -o url=https://storage.googleapis.com \ + -o sigv2 \ + -o nomultipart \ + -o cipher_suites=AESGCM \ + -o stat_cache_expire=20,use_cache=1,max_stat_cache_size=60000 \ + -o max_background=1000 \ + -o max_stat_cache_size=100000 \ + -o multipart_size=52 \ + -o parallel_count=30 \ + -o multireq_max=30 \ + -o dbglevel=warn && tail -f /dev/null