diff --git a/.github/workflows/docd.yml b/.github/workflows/docd.yml new file mode 100644 index 0000000..1a471fc --- /dev/null +++ b/.github/workflows/docd.yml @@ -0,0 +1,33 @@ +name: Release docd + +on: + release: + types: [published] + +jobs: + docker: + name: Publish Docker image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - id: meta + uses: docker/metadata-action@v3 + with: + images: sajari/docd + labels: | + org.opencontainers.image.description=A tool which exposes code.sajari.com/docconv as a service + org.opencontainers.image.title=docd + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - uses: docker/build-push-action@v2 + with: + context: docd + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + push: true diff --git a/README.md b/README.md index 56a4683..14876a5 100644 --- a/README.md +++ b/README.md @@ -50,13 +50,15 @@ The `docd` tool runs as either: 2. a service exposed from within a Docker container - This also runs as a service, but from within a Docker container. There are three build scripts: + This also runs as a service, but from within a Docker container. + Official images are published at https://hub.docker.com/r/sajari/docd. - - [./docd/debian.sh](./docd/debian.sh) - - [./docd/alpine.sh](./docd/alpine.sh) - - [./docd/appengine.sh](./docd/appengine.sh) + Optionally you can build it yourself: - The `debian` version uses the Debian package repository which can vary with builds. The `alpine` version uses a very cut down Linux distribution to produce a container ~40MB. It also locks the dependency versions for consistency, but may miss out on future updates. The `appengine` version is a flex based custom runtime for Google Cloud. + ``` + cd docd + docker build -t docd . + ``` 3. via the command line. diff --git a/docd/Dockerfile b/docd/Dockerfile new file mode 100644 index 0000000..1a61de2 --- /dev/null +++ b/docd/Dockerfile @@ -0,0 +1,28 @@ +FROM golang:1.14 AS build + +WORKDIR /go/src/github.com/sajari/docconv/docd +COPY main.go . +RUN go get -v ./ +RUN go build . + +################################################################################ + +FROM debian:11-slim AS docd + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + lynx \ + poppler-utils \ + tidy \ + unrtf \ + wv \ + zip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +EXPOSE 8888 + +COPY --from=build /go/bin/docd /docd +ENTRYPOINT ["/docd"] +CMD ["--help"] + diff --git a/docd/alpine.sh b/docd/alpine.sh deleted file mode 100755 index 821636f..0000000 --- a/docd/alpine.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env sh - -main() { - export NAME=docd - export VERSION=alpine - - echo "Building ${NAME} for ${VERSION}..." - - GOOS=linux GOARCH=amd64 go build -o $NAME || exit 1 - cp docd $VERSION - cd $VERSION || exit 1 - docker build -t "$NAME:$1" -t "$NAME:latest" . || exit 1 - rm docd -} - -main "$@" \ No newline at end of file diff --git a/docd/alpine/Dockerfile b/docd/alpine/Dockerfile deleted file mode 100644 index 425d046..0000000 --- a/docd/alpine/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM alpine:3.7 - -MAINTAINER Hamish Ogilvy - -ENV CC=/usr/bin/gcc -ENV CXX=/usr/bin/g++ - -COPY dependencies/* / - -RUN apk add --update --no-cache make cmake gcc g++ poppler-utils=0.56.0-r1 wv=1.2.9-r3 lynx=2.8.8_p2-r6 \ - && ./install.sh \ - && apk del make cmake gcc g++ - -EXPOSE 8888 - -COPY docd / -CMD ["/docd"] diff --git a/docd/alpine/dependencies/install.sh b/docd/alpine/dependencies/install.sh deleted file mode 100755 index 22a67d5..0000000 --- a/docd/alpine/dependencies/install.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh - -mkdir /tidy -mkdir /unrtf - -# Install Tidy -tar -C /tidy -xvf tidy-html5-5.4.0.tar.gz -cd /tidy/tidy-html5-5.4.0/build/cmake && \ - cmake ../.. -DCMAKE_BUILD_TYPE=Release && \ - make && \ - make install - -# Install UnRTF -tar -C /unrtf -xvf /unrtf-0.21.9.tar.gz -cd /unrtf/unrtf-0.21.9 && \ - ./configure && make && make install && make clean - -cd / && { - rm -r /tidy - rm -r /unrtf - rm ./*.tar.gz -} \ No newline at end of file diff --git a/docd/alpine/dependencies/tidy-html5-5.4.0.tar.gz b/docd/alpine/dependencies/tidy-html5-5.4.0.tar.gz deleted file mode 100644 index 3898d1f..0000000 Binary files a/docd/alpine/dependencies/tidy-html5-5.4.0.tar.gz and /dev/null differ diff --git a/docd/alpine/dependencies/unrtf-0.21.9.tar.gz b/docd/alpine/dependencies/unrtf-0.21.9.tar.gz deleted file mode 100644 index 11cf91a..0000000 Binary files a/docd/alpine/dependencies/unrtf-0.21.9.tar.gz and /dev/null differ diff --git a/docd/appengine.sh b/docd/appengine.sh deleted file mode 100755 index 3d01dbf..0000000 --- a/docd/appengine.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env sh - -export NAME=docd -export VERSION=appengine - -function die { - echo 1>&2 $* - exit 1 -} - -mkdir appengine/dependencies -cp alpine/dependencies/* appengine/dependencies - -echo "Building ${NAME} for ${VERSION}..." - -GOOS=linux GOARCH=amd64 go build -o $NAME || exit 1 -cp docd $VERSION -cd $VERSION - -echo "Deploying to AppEngine..." -gcloud app deploy --version="1" - -# clean up -rm docd -rm -r appengine/dependencies \ No newline at end of file diff --git a/docd/appengine/Dockerfile b/docd/appengine/Dockerfile index 7029a5d..305b432 100644 --- a/docd/appengine/Dockerfile +++ b/docd/appengine/Dockerfile @@ -1,15 +1,5 @@ -FROM alpine - -MAINTAINER Hamish Ogilvy - -ENV CC=/usr/bin/gcc -ENV CXX=/usr/bin/g++ - -COPY dependencies/* / - -RUN apk add --update --no-cache make cmake gcc g++ poppler-utils~=0.71.0 wv=1.2.9-r3 lynx~=2.8.8; ./install.sh; apk del make cmake gcc g++ - -EXPOSE 8080 - -COPY docd / -CMD ["/docd", "-addr", ":8080"] +# Dockerfile which produces an AppEngine custom runtime containing docd and all +# of its runtime dependencies. +# https://cloud.google.com/appengine/docs/flexible/custom-runtimes/about-custom-runtimes +FROM sajari/docd:1.1.1 +CMD ["-addr", ":8080"] diff --git a/docd/appengine/README.md b/docd/appengine/README.md new file mode 100644 index 0000000..9a4c55c --- /dev/null +++ b/docd/appengine/README.md @@ -0,0 +1,7 @@ +# Deploying docd to AppEngine + +Within this directory run: + +``` +gcloud app deploy +``` diff --git a/docd/appengine/app.yaml b/docd/appengine/app.yaml index 635ab43..ce68f40 100644 --- a/docd/appengine/app.yaml +++ b/docd/appengine/app.yaml @@ -11,4 +11,4 @@ manual_scaling: handlers: - url: /.* - script: _go_app \ No newline at end of file + script: _go_app diff --git a/docd/debian.sh b/docd/debian.sh deleted file mode 100755 index 3817c50..0000000 --- a/docd/debian.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env sh - -export NAME=docd -export VERSION=debian - -function die { - echo 1>&2 $* - exit 1 -} - -echo "Building ${NAME} for ${VERSION}..." - -GOOS=linux GOARCH=amd64 go build -o $NAME || exit 1 -cp docd $VERSION -cd $VERSION -docker build -t $NAME . || exit 1 -rm docd - diff --git a/docd/debian/Dockerfile b/docd/debian/Dockerfile deleted file mode 100644 index 7db1cff..0000000 --- a/docd/debian/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM debian - -MAINTAINER Hamish Ogilvy - -RUN apt-get update && apt-get install -y \ - zip \ - poppler-utils \ - wv \ - unrtf \ - tidy \ - lynx - -EXPOSE 8888 - -COPY docd / -CMD ["/docd"]