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

Add docker container #759

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
74 changes: 74 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build docker

on:
push:
branches:
- master
- main
- build_*
tags:
- v*
pull_request:
branches:
- master
- main

jobs:
buildx:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Login to DockerHub Container Registry
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ secrets.DOCKERHUB_REPO }}/goofys,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
ghcr.io/${{ github.repository }},enable=${{ github.event_name != 'pull_request' }}
tags: |
type=ref,event=tag
type=sha,format=long
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=moby/buildkit:master
-
name: Build multi arch
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64,linux/arm/v7
file: Dockerfile
-
name: Push
if: steps.meta.outputs.tags != ''
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:22.04 as builder
COPY . /build
WORKDIR /build
RUN apt update; apt install -y make git golang-go
RUN make build
FROM ubuntu:22.04
COPY --from=builder /build/goofys /usr/local/bin
COPY run.sh /
RUN chmod +x /run.sh
RUN apt update; apt install -y fuse tini && \
rm -rf /var/cache/apt/archives /var/lib/apt/lists
ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
CMD ["/run.sh"]
4 changes: 0 additions & 4 deletions api/common/panic_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ func (fs FusePanicLogger) ForgetInode(ctx context.Context, op *fuseops.ForgetIno
defer LogPanic(&err)
return fs.Fs.ForgetInode(ctx, op)
}
func (fs FusePanicLogger) BatchForget(ctx context.Context, op *fuseops.BatchForgetOp) (err error) {
defer LogPanic(&err)
return fs.Fs.BatchForget(ctx, op)
}
func (fs FusePanicLogger) MkDir(ctx context.Context, op *fuseops.MkDirOp) (err error) {
defer LogPanic(&err)
return fs.Fs.MkDir(ctx, op)
Expand Down
37 changes: 37 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Failsafe: Stop on errors and unset variables.
set -eu

mkdir -p ~/.aws
if [[ ! -z "${AWS_ACCESS_KEY_ID}" ]] && [[ ! -z "${AWS_SECRET_ACCESS_KEY}" ]]; then
cat <<EOF > ~/.aws/credentials
[default]
aws_access_key_id = $AWS_ACCESS_KEY_ID
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
EOF
fi

exit_script() {
SIGNAL=$1
echo "Caught $SIGNAL! Unmounting ${MNT_POINT}..."
umount ${MNT_POINT}
trap - "$SIGNAL" # clear the trap
exit $?
}

trap "exit_script INT" INT
trap "exit_script TERM" TERM

ARGS=""
if [[ ! -z "${UID}" ]]; then
ARGS="${ARGS} --uid ${UID}"
fi
if [[ ! -z "${GID}" ]]; then
ARGS="${ARGS} --gid ${GID}"
fi
if [[ ! -z "${OPTION}" ]]; then
ARGS="${ARGS} -o ${OPTION}"
fi

goofys -f --endpoint $S3_URL $ARGS $S3_BUCKET $MNT_POINT