mirror of
https://github.com/sajari/docconv.git
synced 2026-10-29 06:17:00 +08:00
docd: refactor Dockerfile and publish to DockerHub (#101)
* Use multi-stage build to compile docd * Bring debian variant up to date * Deprecate the alpine variant * Add GitHub action to publish an official image to DockerHub * Use published image as the AppEngine custom runtime
This commit is contained in:
@@ -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
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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 "$@"
|
||||
@@ -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"]
|
||||
@@ -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
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
@@ -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"]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Deploying docd to AppEngine
|
||||
|
||||
Within this directory run:
|
||||
|
||||
```
|
||||
gcloud app deploy
|
||||
```
|
||||
@@ -11,4 +11,4 @@ manual_scaling:
|
||||
|
||||
handlers:
|
||||
- url: /.*
|
||||
script: _go_app
|
||||
script: _go_app
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
Reference in New Issue
Block a user