diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ee6ddf2..2896c04 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -8,8 +8,12 @@ jobs: # First we build the docker container, then we run CI tests build: runs-on: ubuntu-latest + strategy: + matrix: + debian_base: [bullseye, bookworm] env: DOCKER_IMAGE: fstalign + DEBIAN_BASE: ${{ matrix.debian_base }} steps: - name: Checkout repository and submodules @@ -18,7 +22,10 @@ jobs: submodules: recursive - name: Build the docker container - run: docker build . -f Dockerfile -t ${DOCKER_IMAGE} + run: | + docker build . -f Dockerfile \ + --build-arg DEBIAN_BASE=${DEBIAN_BASE} \ + -t ${DOCKER_IMAGE}:${DEBIAN_BASE} - name: Run CI tests - run: docker run --rm -t ${DOCKER_IMAGE} bash -c '(cd build && make test)' + run: docker run --rm -t ${DOCKER_IMAGE}:${DEBIAN_BASE} bash -c '(cd build && make test)' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e56f530..00a4ba0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,6 +6,11 @@ jobs: push_to_registry: name: Push Docker image to GitHub Packages runs-on: ubuntu-latest + strategy: + matrix: + debian_base: [bullseye, bookworm] + env: + DEBIAN_BASE: ${{ matrix.debian_base }} steps: - name: Check out the repo @@ -22,7 +27,10 @@ jobs: if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} fi - TAGS="${DOCKER_IMAGE}:${VERSION}" + TAGS="${DOCKER_IMAGE}:${VERSION}-${DEBIAN_BASE}" + if [ "${DEBIAN_BASE}" = "bullseye" ]; then + TAGS="${TAGS} ${DOCKER_IMAGE}:${VERSION} ${DOCKER_IMAGE}:latest" + fi echo ::set-output name=version::${VERSION} echo ::set-output name=tags::${TAGS} echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') @@ -45,6 +53,6 @@ jobs: context: . platforms: linux/amd64 push: true - tags: | - revdotcom/fstalign:latest - ${{ steps.prep.outputs.tags }} + build-args: | + DEBIAN_BASE=${{ env.DEBIAN_BASE }} + tags: ${{ steps.prep.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index 347925f..9497499 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,54 @@ -# Using kaldi image for pre-built OpenFST, version is 1.7.2 -FROM kaldiasr/kaldi:cpu-debian10-2024-07-29 as kaldi-base +ARG DEBIAN_BASE=bullseye +FROM debian:${DEBIAN_BASE}-slim AS debian-base +RUN echo "APT::Get::Assume-Yes \"true\";\nAPT::Get::allow \"true\";" | tee -a /etc/apt/apt.conf.d/90_no_prompt && \ + echo "APT::Keep-Downloaded-Packages \"false\";" | tee -a /etc/apt/apt.conf.d/91_no_cache && \ + apt-get update +# Stage 1: Build OpenFST 1.7.2 from source +FROM debian-base as openfst-builder -FROM debian:11 +ARG OPENFST_VERSION=1.7.2 +ARG JOBS=4 + +# Install build dependencies for OpenFST +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y --no-install-recommends \ + g++ \ + make \ + ccache \ + && rm -rf /var/lib/apt/lists/* + +# Copy and build OpenFST from local tarball +WORKDIR /tmp +COPY ext/openfst-${OPENFST_VERSION}.tar.gz /tmp/ +RUN --mount=type=cache,target=/root/.ccache,sharing=locked \ + PATH=/usr/lib/ccache:${PATH} \ + tar -xzf openfst-${OPENFST_VERSION}.tar.gz && \ + cd openfst-${OPENFST_VERSION} && \ + ./configure --prefix=/opt/openfst --enable-shared --enable-static && \ + make -j${JOBS} && \ + make install && \ + cd .. && \ + rm -rf openfst-${OPENFST_VERSION} openfst-${OPENFST_VERSION}.tar.gz + +# Stage 2: Build fstalign +FROM debian-base -COPY --from=kaldi-base /opt/kaldi/tools/openfst /opt/openfst +COPY --from=openfst-builder /opt/openfst /opt/openfst ENV OPENFST_ROOT /opt/openfst ARG JOBS=4 +# Install runtime and build dependencies RUN apt-get update && \ apt-get upgrade -y && \ - apt-get -y install \ + apt-get install -y --no-install-recommends \ cmake \ g++ \ - libicu-dev + make \ + ccache \ + libicu-dev \ + && rm -rf /var/lib/apt/lists/* RUN mkdir /fstalign COPY CMakeLists.txt /fstalign/CMakeLists.txt @@ -24,10 +59,12 @@ COPY sample_data /fstalign/sample_data WORKDIR /fstalign -RUN mkdir -p /fstalign/build && \ +RUN --mount=type=cache,target=/root/.ccache,sharing=locked \ + PATH=/usr/lib/ccache:${PATH} \ + mkdir -p /fstalign/build && \ cd /fstalign/build && \ rm -rf * && \ - cmake .. -DOPENFST_ROOT="${OPENFST_ROOT}" -DDYNAMIC_OPENFST=ON && \ + cmake .. -DOPENFST_ROOT="${OPENFST_ROOT}" -DDYNAMIC_OPENFST=OFF && \ make -j${JOBS} VERBOSE=1 && \ mkdir -p /fstalign/bin && \ cp /fstalign/build/fstalign /fstalign/bin && \ diff --git a/ext/openfst-1.7.2.tar.gz b/ext/openfst-1.7.2.tar.gz new file mode 100755 index 0000000..b5e34b5 Binary files /dev/null and b/ext/openfst-1.7.2.tar.gz differ diff --git a/src/FstFileLoader.h b/src/FstFileLoader.h index 42dcdeb..b9102be 100644 --- a/src/FstFileLoader.h +++ b/src/FstFileLoader.h @@ -3,7 +3,8 @@ * * FstLoader for loading a serialized FST from disk. * - * Quinn McNamara (quinn@rev.com) + * Jp Robichaud (jp@rev.com) + * Quinn McNamara () * 2020 */ diff --git a/src/wer.h b/src/wer.h index b66e978..70fcf0c 100644 --- a/src/wer.h +++ b/src/wer.h @@ -3,7 +3,8 @@ * * Collection of functions specific to the WER subcommand. * - * Quinn McNamara (quinn@rev.com) + * Jp Robichaud (jp@rev.com) + * Quinn McNamara () * 2021 */ #include "fstalign.h" diff --git a/third-party/catch2 b/third-party/catch2 index 62460fa..62fd660 160000 --- a/third-party/catch2 +++ b/third-party/catch2 @@ -1 +1 @@ -Subproject commit 62460fafe6b54c3173bc5cbc46d05a5f071017ff +Subproject commit 62fd660583d3ae7a7886930b413c3c570e89786c