Skip to content

Commit

Permalink
Fix dockerfile / linux build script (#50)
Browse files Browse the repository at this point in the history
* Remove specific branch name from `Dockerfile.`

* Improve `build-linux.sh`.
  • Loading branch information
justinkambic authored Feb 19, 2023
1 parent 7ddf86f commit 0531e04
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN curl https://www.libraw.org/data/LibRaw-0.21.1.tar.gz --output LibRaw-0.21.1
RUN tar xzvf LibRaw-0.21.1.tar.gz && cd LibRaw-0.21.1 && ./configure --with-pic --disable-openmp && touch * && make && make install && cd ../
RUN npm i -g node-gyp node-gyp-build prebuildify
RUN git clone https://github.com/justinkambic/libraw.js.git
RUN cd libraw.js && git checkout upgrade-to-libraw-21.1 && npm install && npm run format-check && npm run lint && npm run build && npm test && prebuildify --napi
RUN cd libraw.js && git pull origin master && npm install && npm run format-check && npm run lint && npm run build && npm test && prebuildify --napi

WORKDIR /libraw.js

Expand Down
24 changes: 23 additions & 1 deletion build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,37 @@ CURRENT_LIBRAWJS_VERSION=2.3.0
PREBUILD_PATH="prebuilds/linux-x64"
NODE_FILE_NAME="node.napi.node"
OUTPUT_PATH="./${PREBUILD_PATH}/${NODE_FILE_NAME}"
BACKUP_PATH="./${PREBUILD_PATH}/bak.${NODE_FILE_NAME}"
IMAGE_TAG_NAME="libraw.js:${CURRENT_LIBRAWJS_VERSION}"

echo "Output path is ${OUTPUT_PATH}";

if [ ! -d ${PREBUILD_PATH} ]; then
echo "Linux prebuild dir does not exist, creating.";
mkdir -p ${PREBUILD_PATH};
else
echo "Linux prebuild dir exists.";
fi

if [ -f ${OUTPUT_PATH} ]; then
echo "Linux prebuild file exists. Backing up.";
mv ${OUTPUT_PATH} ${BACKUP_PATH};
fi

DOCKER_BUILDKIT=1

docker build -t ${IMAGE_TAG_NAME} --output ${OUTPUT_PATH} .
docker build -t ${IMAGE_TAG_NAME} --output ${PREBUILD_PATH} --no-cache .

DOCKER_EXIT_CODE=$?

if [ -f ${BACKUP_PATH} ] && [ $DOCKER_EXIT_CODE -eq 0 ]; then
echo "Binary build succeeded. Deleting backup file."
rm ${BACKUP_PATH};
fi

if [ $DOCKER_EXIT_CODE -eq 0 ]; then
echo "Linux build complete.";
else
echo "Docker build failed."
exit 1;
fi

0 comments on commit 0531e04

Please sign in to comment.