2023-10-04 12:00:32 +02:00
|
|
|
FROM emscripten/emsdk:latest as build
|
|
|
|
|
|
|
|
# Used to invalidate layer cache but not mount cache
|
|
|
|
# See https://github.com/moby/moby/issues/41715#issuecomment-733976493
|
|
|
|
ARG UNIQUEKEY 1
|
|
|
|
|
|
|
|
RUN apt update
|
|
|
|
RUN apt install -y git ccache autoconf automake libtool cmake pkg-config
|
|
|
|
|
2023-10-10 16:58:43 +02:00
|
|
|
RUN <<EOF
|
2023-10-04 12:00:32 +02:00
|
|
|
# Install vcpkg
|
2023-10-14 13:31:37 +02:00
|
|
|
# Note: we are a patch on the libmagic port
|
2023-10-10 16:58:43 +02:00
|
|
|
set -xe
|
|
|
|
|
2023-10-14 13:31:37 +02:00
|
|
|
git clone https://github.com/microsoft/vcpkg /vcpkg
|
2023-10-10 16:58:43 +02:00
|
|
|
/vcpkg/bootstrap-vcpkg.sh
|
|
|
|
sed -i 's/vcpkg_install_make(${EXTRA_ARGS})/vcpkg_install_make(${EXTRA_ARGS} SUBPATH src)/g' /vcpkg/ports/libmagic/portfile.cmake
|
|
|
|
EOF
|
2023-10-04 12:00:32 +02:00
|
|
|
|
|
|
|
# Patch vcpkg build instructions to add -pthread
|
|
|
|
RUN <<EOF
|
|
|
|
set -xe
|
|
|
|
|
|
|
|
echo '
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
|
|
|
' >> /emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
|
|
|
|
EOF
|
|
|
|
|
2023-10-05 00:08:34 +02:00
|
|
|
ENV VCPKG_DEFAULT_BINARY_CACHE /cache/vcpkg
|
|
|
|
RUN --mount=type=cache,target=/cache <<EOF
|
2023-10-04 12:00:32 +02:00
|
|
|
# Install dependencies with vcpkg
|
2023-10-05 00:08:34 +02:00
|
|
|
set -xe
|
|
|
|
|
|
|
|
mkdir -p $VCPKG_DEFAULT_BINARY_CACHE
|
|
|
|
|
|
|
|
/vcpkg/vcpkg install --triplet=wasm32-emscripten libmagic
|
|
|
|
/vcpkg/vcpkg install --triplet=wasm32-emscripten freetype
|
|
|
|
/vcpkg/vcpkg install --triplet=wasm32-emscripten mbedtls
|
2023-12-31 11:39:24 +01:00
|
|
|
/vcpkg/vcpkg install --triplet=wasm32-emscripten zlib
|
|
|
|
/vcpkg/vcpkg install --triplet=wasm32-emscripten bzip2
|
|
|
|
/vcpkg/vcpkg install --triplet=wasm32-emscripten liblzma
|
|
|
|
/vcpkg/vcpkg install --triplet=wasm32-emscripten zstd
|
2023-10-05 00:08:34 +02:00
|
|
|
EOF
|
2023-10-04 12:00:32 +02:00
|
|
|
|
|
|
|
# Build ImHex
|
|
|
|
ARG JOBS=4
|
|
|
|
ENV CCACHE_DIR /cache/ccache
|
|
|
|
|
|
|
|
RUN mkdir /build
|
|
|
|
WORKDIR /build
|
|
|
|
RUN --mount=type=cache,target=/cache \
|
|
|
|
--mount=type=bind,source=.,target=/imhex <<EOF
|
|
|
|
|
|
|
|
set -xe
|
|
|
|
ccache -zs
|
|
|
|
|
|
|
|
cmake /imhex \
|
|
|
|
-DIMHEX_OFFLINE_BUILD=ON \
|
|
|
|
-DIMHEX_STATIC_LINK_PLUGINS=ON \
|
2023-12-23 21:09:41 +01:00
|
|
|
-DIMHEX_EXCLUDE_PLUGINS="script_loader" \
|
2023-10-04 12:00:32 +02:00
|
|
|
-DNATIVE_CMAKE_C_COMPILER=gcc \
|
|
|
|
-DNATIVE_CMAKE_CXX_COMPILER=g++ \
|
|
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
|
|
|
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
|
|
|
|
|
|
make -j $JOBS
|
|
|
|
|
|
|
|
cp /imhex/dist/web/source/* /build
|
|
|
|
ccache -s
|
|
|
|
EOF
|
|
|
|
|
2024-01-26 19:52:05 +01:00
|
|
|
FROM scratch as raw
|
2023-10-04 12:00:32 +02:00
|
|
|
COPY --from=build [ \
|
|
|
|
# ImHex \
|
|
|
|
"/build/imhex.wasm", \
|
|
|
|
"/build/imhex.js", \
|
|
|
|
"/build/imhex.worker.js", \
|
|
|
|
\
|
|
|
|
# Static files \
|
|
|
|
"/build/index.html", \
|
|
|
|
"/build/style.css", \
|
|
|
|
"/build/wasm-config.js", \
|
|
|
|
"/build/enable-threads.js", \
|
|
|
|
"/build/favicon.ico", \
|
2023-10-17 09:31:56 +02:00
|
|
|
"/build/icon.png", \
|
|
|
|
"/build/manifest.json", \
|
2023-12-09 13:35:06 +01:00
|
|
|
"/build/robots.txt", \
|
|
|
|
"/build/sitemap.xml", \
|
2023-10-04 12:00:32 +02:00
|
|
|
\
|
|
|
|
# Destination \
|
|
|
|
"./" \
|
2024-01-26 19:52:05 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
FROM nginx
|
|
|
|
COPY --from=raw . /usr/share/nginx/html
|