-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
95 lines (84 loc) · 3.9 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Copyright (C) 2018 Christian Berger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
FROM chrberger/javascript-libcluon-builder:latest
MAINTAINER Christian Berger "christian.berger@gu.se"
# Set the env variable DEBIAN_FRONTEND to noninteractive
ENV DEBIAN_FRONTEND noninteractive
# Install necessary tools.
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get dist-upgrade -y && \
apt-get install -y --no-install-recommends \
npm \
wget \
unzip \
zip
RUN npm install typescript@1.6.2 -g
ADD . /opt/sources
WORKDIR /opt/sources
RUN cd /opt && \
wget https://dl.google.com/closure-compiler/compiler-20180716.zip && \
unzip compiler-20180716.zip
# Use Bash by default from now.
SHELL ["/bin/bash", "-c"]
# Build openh264_decoder.js.
RUN source /opt/emsdk/emsdk_env.sh && \
cd /opt/sources && \
cd codecs/openh264 && \
patch -p1 < ../../patches/openh264-v1.8.0.patch && \
emmake make libopenh264.a && \
cd /opt/sources && \
mkdir -p build && cd build && \
tsc --out .openh264_decoder.js ../openh264_decoder.ts && \
emcc -o /tmp/openh264_decoder.js \
-O3 --llvm-lto 1 --memory-init-file 0 \
-s BUILD_AS_WORKER=1 -s TOTAL_MEMORY=67108864 \
-s NO_FILESYSTEM=1 \
-s EXPORTED_FUNCTIONS="['_malloc']" \
-s EXPORTED_RUNTIME_METHODS="['setValue', 'getValue']" \
-I /opt/sources/codecs/openh264/codec/api/svc \
-s EXPORTED_FUNCTIONS="['_WelsCreateDecoder','_WelsInitializeDecoder','_WelsDecoderDecodeFrame','_SizeOfSBufferInfo']" \
--post-js .openh264_decoder.js \
/opt/sources/codecs/openh264/libopenh264.a ../bindings/openh264.c && \
java -jar /opt/closure-compiler-v*.jar --js /tmp/openh264_decoder.js --js_output_file /tmp/openh264_decoder.js.2 && \
mv /tmp/openh264_decoder.js.2 /tmp/openh264_decoder.js
# Build vpx_decoder.js.
RUN source /opt/emsdk/emsdk_env.sh && \
cd /opt/sources && \
cd codecs/libvpx && \
patch -p1 < ../../patches/libvpx-992d9a0.patch && \
emconfigure ./configure \
--disable-multithread \
--target=generic-gnu \
--disable-docs \
--disable-examples && \
emmake make libvpx_g.a && \
cd /opt/sources && \
mkdir -p build && cd build && \
tsc --out .libvpx_decoder.js ../libvpx_decoder.ts && \
emcc -o /tmp/libvpx_decoder.js \
-O3 --llvm-lto 1 --memory-init-file 0 \
-s BUILD_AS_WORKER=1 -s TOTAL_MEMORY=67108864 \
-s NO_FILESYSTEM=1 \
-s EXPORTED_FUNCTIONS="['_malloc']" \
-s EXPORTED_RUNTIME_METHODS="['setValue', 'getValue']" \
-I /opt/sources/codecs/libvpx/vpx \
-s EXPORTED_FUNCTIONS="['_vpx_codec_vp8_dx','_vpx_codec_vp9_dx','_vpx_codec_dec_init2','_allocate_vpx_codec_ctx','_vpx_codec_dec_init_ver','_vpx_codec_decode','_vpx_codec_get_frame']" \
--post-js .libvpx_decoder.js \
/opt/sources/codecs/libvpx/libvpx_g.a ../bindings/libvpx.c && \
java -jar /opt/closure-compiler-v*.jar --js /tmp/libvpx_decoder.js --js_output_file /tmp/libvpx_decoder.js.2 && \
mv /tmp/libvpx_decoder.js.2 /tmp/libvpx_decoder.js
# When running a Docker container based on this image, simply copy the results to /opt/output.
CMD mkdir -p /opt/sources/output && cp /tmp/openh264_decoder.js /tmp/libvpx_decoder.js /opt/sources/output/