Skip to content

Instantly share code, notes, and snippets.

@onpaws
Last active April 20, 2023 23:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onpaws/ffed3040f8b0c4db435e19ceb4a59a8f to your computer and use it in GitHub Desktop.
Save onpaws/ffed3040f8b0c4db435e19ceb4a59a8f to your computer and use it in GitHub Desktop.
# syntax=docker/dockerfile:1
### Seafowl https://github.com/splitgraph/seafowl/blob/main/Dockerfile
# Assumes Seafowl binary is already present
# Download from https://github.com/splitgraph/seafowl/releases
FROM debian:bullseye-slim
COPY ./seafowl /usr/local/bin/seafowl
# Make sure to install ca-certificates so that we can use HTTPS
# https://github.com/debuerreotype/docker-debian-artifacts/issues/15
RUN \
apt-get update -qq && \
apt-get install -y --no-install-recommends ca-certificates curl gnupg && \
update-ca-certificates && \
mkdir -p /seafowl-data && \
mkdir -p /etc/seafowl
# TODO: probably OK to remove this since we're on object_store anyway
# Make /seafowl-data a volume
# This is not required for bind mounting, but will create an anonymous volume
# on startup for persistence
# https://docs.docker.com/engine/reference/builder/#volume
VOLUME [ "/seafowl-data" ]
### gcsfuse https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/run/filesystem/Dockerfile
# Install system dependencies
RUN set -e; \
apt-get install -y \
tini \
lsb-release; \
gcsFuseRepo=gcsfuse-`lsb_release -c -s`; \
echo "deb http://packages.cloud.google.com/apt $gcsFuseRepo main" | \
tee /etc/apt/sources.list.d/gcsfuse.list; \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
apt-key add -; \
apt-get update; \
apt-get install -y gcsfuse \
&& apt-get clean
# Set fallback mount directory
ENV MNT_DIR /mnt/gcs
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
# Ensure the script is executable
RUN chmod +x /app/gcsfuse_run.sh
# Use tini to manage zombie processes and signal forwarding
# https://github.com/krallin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]
# Pass the startup script as arguments to Tini
CMD ["/app/gcsfuse_run.sh"]
#!/usr/bin/env bash
set -eo pipefail
# Create mount directory for service
mkdir -p $MNT_DIR
echo "Mounting GCS Fuse."
gcsfuse --debug_gcs --debug_fuse $BUCKET $MNT_DIR
echo "Mounting completed."
# Cloud Run suggests we honor $PORT, wire it in as an env var
exec env SEAFOWL__FRONTEND__HTTP_BIND_PORT=$PORT seafowl -c /etc/seafowl/seafowl.toml &
# Exit immediately when one of the background processes terminate.
wait -n
# [END cloudrun_fuse_script]
# See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/run/filesystem/gcsfuse_run.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment