Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Create Docker image for CCExtractor #1611

Merged
merged 10 commits into from
Jul 17, 2024
61 changes: 61 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# CCExtractor Docker image

This dockerfile prepares a minimalist Docker image with CCExtractor. It compiles CCExtractor from sources following instructions from the [Compilation Guide](https://github.com/CCExtractor/ccextractor/blob/master/docs/COMPILATION.MD).

You can install the latest build of this image by running `docker pull CCExtractor/ccextractor`

## Build

You can build the Docker image directly from the Dockerfile provided in [docker](https://github.com/CCExtractor/ccextractor/tree/master/docker) directory of CCExtractor source

```bash
$ git clone https://github.com/CCExtractor/ccextractor.git && cd ccextractor
$ cd docker/
$ docker build -t ccextractor .
```

## Usage

The CCExtractor Docker image can be used in several ways, depending on your needs.

```bash
# General usage
$ docker run ccextractor:latest <features>
```

1. Process a local file & use `-o` flag

To process a local video file, mount a directory containing the input file inside the container:

```bash
# Use `-o` to specifying output file
$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) ccextractor:latest input.mp4 -o output.srt

# Alternatively use `--stdout` feature
$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) ccextractor:latest input.mp4 --stdout > output.srt
```

Run this command from where your input video file is present, and change `input.mp4` & `output.srt` with the actual name of files.

2. Enter an interactive environment

If you need to run CCExtractor with additional options or perform other tasks within the container, you can enter an interactive environment:
bash

```bash
$ docker run --rm -it --entrypoint='sh' ccextractor:latest
```

This will start a Bash shell inside the container, allowing you to run CCExtractor commands manually or perform other operations.

### Example

I run help command in image built from `dockerfile`

```bash
$ docker build -t ccextractor .
$ docker run --rm ccextractor:latest --help
```

This will show the `--help` message of CCExtractor tool
From there you can see all the features and flags which can be used.
48 changes: 48 additions & 0 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM alpine:latest as base

FROM base as builder

RUN apk add --no-cache --update git curl gcc cmake glew glfw \
tesseract-ocr-dev leptonica-dev clang-dev llvm-dev make pkgconfig \
zlib-dev libpng-dev libjpeg-turbo-dev openssl-dev freetype-dev libxml2-dev

RUN cd && git clone https://github.com/gpac/gpac
WORKDIR root/gpac/
RUN ./configure && make && make install-lib && cd && rm -rf /root/gpac

WORKDIR /root
RUN git clone https://github.com/CCExtractor/ccextractor.git
RUN apk add bash cargo
RUN export LIB_CLANG_PATH=$(find / -name 'libclang*.so*' 2>/dev/null | grep -v 'No such file' | head -n 1 | xargs dirname)
RUN cd /root/ccextractor/linux && ./pre-build.sh && ./build

RUN cp /root/ccextractor/linux/ccextractor /ccextractor && rm -rf ~/ccextractor

FROM base as final

COPY --from=builder /lib/ld-musl-x86_64.so.1 /lib/
COPY --from=builder /usr/lib/libtesseract.so.5 /usr/lib/
COPY --from=builder /usr/lib/libleptonica.so.6 /usr/lib/
COPY --from=builder /usr/local/lib/libgpac.so.12 /usr/local/lib/
COPY --from=builder /usr/lib/libstdc++.so.6 /usr/lib/
COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/
COPY --from=builder /usr/lib/libgomp.so.1 /usr/lib/
COPY --from=builder /usr/lib/libpng16.so.16 /usr/lib/
COPY --from=builder /usr/lib/libjpeg.so.8 /usr/lib/
COPY --from=builder /usr/lib/libgif.so.7 /usr/lib/
COPY --from=builder /usr/lib/libtiff.so.6 /usr/lib/
COPY --from=builder /usr/lib/libwebp.so.7 /usr/lib/
COPY --from=builder /usr/lib/libwebpmux.so.3 /usr/lib/
COPY --from=builder /lib/libz.so.1 /lib/
COPY --from=builder /lib/libssl.so.3 /lib/
COPY --from=builder /lib/libcrypto.so.3 /lib/
COPY --from=builder /usr/lib/liblzma.so.5 /usr/lib/
COPY --from=builder /usr/lib/libzstd.so.1 /usr/lib/
COPY --from=builder /usr/lib/libsharpyuv.so.0 /usr/lib/

COPY --from=builder /ccextractor /

ENTRYPOINT [ "/ccextractor" ]

CMD [ "/ccextractor" ]

1 change: 1 addition & 0 deletions docs/CHANGES.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.95 (to be released)
-----------------
- New: Create a Docker image to simplify the CCExtractor usage without any environmental hustle (#1611)
- New: Add time units module in lib_ccxr (#1623)
- New: Add bits and levenshtein module in lib_ccxr (#1627)
- New: Add constants module in lib_ccxr (#1624)
Expand Down
3 changes: 3 additions & 0 deletions docs/COMPILATION.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Clone the latest repository from Github
git clone https://github.com/CCExtractor/ccextractor.git
```

## Docker
You can now use docker image to build latest source of CCExtractor without any environmental hustle. Follow these [instructions](https://github.com/CCExtractor/ccextractor/tree/master/docker/README.md) for building docker image & usage of it.

## Linux

1. Make sure all the dependencies are met.
Expand Down