Skip to content

Instantly share code, notes, and snippets.

@mvsantos
Last active June 4, 2019 21:40
Show Gist options
  • Save mvsantos/17048cf18655da2afeda9fc206574dad to your computer and use it in GitHub Desktop.
Save mvsantos/17048cf18655da2afeda9fc206574dad to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
__DIR__="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPENREFINE_VERSION=${OPENREFINE_VERSION:-3.1}
INSTALL_PATH="${INSTALL_PATH:-${HOME}/.openrefine}"
echo "Installing OpenRefine version '${OPENREFINE_VERSION}'"
echo "A 'Dockerfile' will be created in ${INSTALL_PATH}"
echo "and your projects' sources are expected to found in ${INSTALL_PATH}/projects"
mkdir -p "${INSTALL_PATH}/projects"
cd "${INSTALL_PATH}"
[[ -f Dockerfile ]] && rm -f Dockerfile
touch Dockerfile
cat <<EOT >> Dockerfile
## Build the image
# docker build -f Dockerfile --force-rm --rm -t openrefine:${OPENREFINE_VERSION} .
#
## Run the container in the background
# docker run -d -ti -v "\$(pwd)/projects:/data" -p 3333:3333 --rm --name openrefine openrefine:${OPENREFINE_VERSION}
FROM java:8-jre-alpine
ENV OPENREFINE_VERSION ${OPENREFINE_VERSION}
ENV OPENREFINE_FILE openrefine-linux-\${OPENREFINE_VERSION}.tar.gz
ENV OPENREFINE_URL https://github.com/OpenRefine/OpenRefine/releases/download/\${OPENREFINE_VERSION}/\${OPENREFINE_FILE}
WORKDIR /app
RUN apk update
RUN set -xe \
&& apk add --no-cache bash curl jq tar \
&& curl -sSL \${OPENREFINE_URL} | tar xz --strip 1
WORKDIR /data
VOLUME /data
EXPOSE 3333
ENTRYPOINT ["/app/refine"]
CMD ["-i", "0.0.0.0", "-d", "/data", "-m", "2048M"]
EOT
# Exclude project data from the build context
cat <<EOT >> .dockerignore
*/projects/*
EOT
# Build image
docker build -f Dockerfile --force-rm --rm -t openrefine:${OPENREFINE_VERSION} .
# Leave the Docker container running on the foreground
docker run -d -ti -v "$(pwd)/projects:/data" -p 3333:3333 --rm --name openrefine openrefine:${OPENREFINE_VERSION}
open -a "Google Chrome.app" http://127.0.0.1:3333/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment