-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ZIMkaRU/feature/isolate-electron-builder-…
…env-into-docker-containers Isolate electron builder env into docker containers
- Loading branch information
Showing
11 changed files
with
323 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
**/node_modules | ||
**/.env | ||
bfx-reports-framework/db/*.db | ||
bfx-reports-framework/db/*.json | ||
bfx-reports-framework/config/*.json | ||
bfx-reports-framework/config/facs/*.json | ||
bfx-reports-framework/logs/*.log | ||
bfx-reports-framework/csv | ||
bfx-report-ui/build | ||
bfx-report-ui/bfx-report-express/logs/*.log | ||
bfx-report-ui/bfx-report-express/config/*.json | ||
docker-compose.yaml | ||
Dockerfile.linux-builder | ||
Dockerfile.win-builder | ||
Dockerfile.mac-builder | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM electronuserland/builder:10 | ||
|
||
RUN apt-get install -y --no-install-recommends \ | ||
p7zip-full \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . . | ||
|
||
ENTRYPOINT ["./init.sh"] | ||
CMD ["-p", "linux", "-u"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM electronuserland/builder:10 | ||
|
||
RUN apt-get install -y --no-install-recommends \ | ||
p7zip-full \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . . | ||
|
||
ENTRYPOINT ["./init.sh"] | ||
CMD ["-p", "mac", "-u"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM electronuserland/builder:10 | ||
|
||
COPY . . | ||
|
||
ENTRYPOINT ["./build-ui.sh"] | ||
CMD ["-i"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM electronuserland/builder:wine-05.18 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
p7zip-full \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . . | ||
|
||
ENTRYPOINT ["./init.sh"] | ||
CMD ["-p", "win", "-u"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
export NODE_PATH=src/ | ||
export PUBLIC_URL=/ | ||
export REACT_APP_PLATFORM=localhost | ||
export REACT_APP_TITLE=Bitfinex Reports | ||
export REACT_APP_LOGO_PATH=favicon.ico | ||
export REACT_APP_ELECTRON=true | ||
|
||
ROOT=$PWD | ||
frontendFolder="$ROOT/bfx-report-ui" | ||
uiBuildFolder=/ui-build | ||
uiReadyFile="$uiBuildFolder/READY" | ||
|
||
programname=$0 | ||
isDevEnv=0 | ||
isInitedSubmodules=0 | ||
|
||
rm -rf $uiBuildFolder/* | ||
|
||
function usage { | ||
echo "Usage: $programname [-d] | [-h]" | ||
echo " -d turn on developer environment" | ||
echo " -h display help" | ||
exit 1 | ||
} | ||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
-d | --dev ) isDevEnv=1 | ||
;; | ||
-i | --init ) isInitedSubmodules=1 | ||
;; | ||
-h | --help ) usage | ||
exit | ||
;; | ||
* ) usage | ||
exit 1 | ||
esac | ||
shift | ||
done | ||
|
||
if [ $isDevEnv != 0 ]; then | ||
echo "Developer environment is turned on" | ||
fi | ||
|
||
if [ $isInitedSubmodules != 0 ]; then | ||
git submodule foreach --recursive git git clean -fdx | ||
git submodule foreach --recursive git reset --hard HEAD | ||
git submodule sync | ||
git submodule update --init --recursive | ||
git config url."https://github.com/".insteadOf [email protected]: | ||
git pull --recurse-submodules | ||
git submodule update --remote --recursive | ||
fi | ||
|
||
cd $frontendFolder | ||
|
||
if ! [ -s "$frontendFolder/package.json" ]; then | ||
exit 1 | ||
fi | ||
|
||
npm i | ||
|
||
sed -i -e "s/API_URL: .*,/API_URL: \'http:\/\/localhost:34343\/api\',/g" $frontendFolder/src/var/config.js | ||
sed -i -e "s/WS_ADDRESS: .*,/WS_ADDRESS: \'ws:\/\/localhost:34343\/ws\',/g" $frontendFolder/src/var/config.js | ||
|
||
if [ $isDevEnv != 0 ]; then | ||
sed -i -e "s/KEY_URL: .*,/KEY_URL: \'https:\/\/test.bitfinex.com\/api\',/g" $frontendFolder/src/var/config.js | ||
fi | ||
|
||
sed -i -e "s/showAuthPage: .*,/showAuthPage: true,/g" $frontendFolder/src/var/config.js | ||
sed -i -e "s/showSyncMode: .*,/showSyncMode: true,/g" $frontendFolder/src/var/config.js | ||
sed -i -e "s/showFrameworkMode: .*,/showFrameworkMode: true,/g" $frontendFolder/src/var/config.js | ||
npm run build | ||
|
||
mv -f $frontendFolder/build/* $uiBuildFolder | ||
touch $uiReadyFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
version: '3.7' | ||
|
||
services: | ||
ui-builder: | ||
container_name: ui-builder | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.ui-builder | ||
volumes: | ||
- ui-build:/ui-build | ||
|
||
linux-builder: | ||
container_name: linux-builder | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.linux-builder | ||
environment: | ||
ELECTRON_CACHE: /root/.cache/electron | ||
ELECTRON_BUILDER_CACHE: /root/.cache/electron-builder | ||
volumes: | ||
- ui-build:/ui-build | ||
- ./dist:/dist | ||
- electron-cache:/root/.cache/electron | ||
- electron-builder-cache:/root/.cache/electron-builder | ||
|
||
win-builder: | ||
container_name: win-builder | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.win-builder | ||
environment: | ||
ELECTRON_CACHE: /root/.cache/electron | ||
ELECTRON_BUILDER_CACHE: /root/.cache/electron-builder | ||
volumes: | ||
- ui-build:/ui-build | ||
- ./dist:/dist | ||
- electron-cache:/root/.cache/electron | ||
- electron-builder-cache:/root/.cache/electron-builder | ||
|
||
mac-builder: | ||
container_name: mac-builder | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.mac-builder | ||
environment: | ||
ELECTRON_CACHE: /root/.cache/electron | ||
ELECTRON_BUILDER_CACHE: /root/.cache/electron-builder | ||
volumes: | ||
- ui-build:/ui-build | ||
- ./dist:/dist | ||
- electron-cache:/root/.cache/electron | ||
- electron-builder-cache:/root/.cache/electron-builder | ||
|
||
volumes: | ||
ui-build: | ||
electron-cache: | ||
electron-builder-cache: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,13 @@ | |
|
||
set -x | ||
|
||
export NODE_PATH=src/ | ||
export PUBLIC_URL=/ | ||
export REACT_APP_PLATFORM=localhost | ||
export REACT_APP_TITLE=Bitfinex Reports | ||
export REACT_APP_LOGO_PATH=favicon.ico | ||
export REACT_APP_ELECTRON=true | ||
|
||
ROOT=$PWD | ||
|
||
programname=$0 | ||
isDevEnv=0 | ||
isNotSkippedReiDeps=1 | ||
targetPlatform=0 | ||
isSkippedUIBuild=0 | ||
|
||
function usage { | ||
echo "Usage: $programname [-d] | [-h]" | ||
|
@@ -22,12 +17,37 @@ function usage { | |
exit 1 | ||
} | ||
|
||
function getConfValue { | ||
local dep="" | ||
local value="" | ||
|
||
if [ $# -ge 1 ] | ||
then | ||
dep=$1 | ||
else | ||
exit 1 | ||
fi | ||
|
||
version=$(cat $ROOT/package.json \ | ||
| grep \"$dep\" \ | ||
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[",]//g' \ | ||
| tr -d '[[:space:]]') | ||
|
||
echo $version | ||
} | ||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
-d | --dev ) isDevEnv=1 | ||
;; | ||
-s | --skip-rei-deps ) isNotSkippedReiDeps=0 | ||
;; | ||
-p | --target-platform ) targetPlatform=$2; shift | ||
;; | ||
-u | --skip-ui-build ) isSkippedUIBuild=1 | ||
;; | ||
-h | --help ) usage | ||
exit | ||
;; | ||
|
@@ -44,38 +64,31 @@ fi | |
frontendFolder="$ROOT/bfx-report-ui" | ||
expressFolder="$frontendFolder/bfx-report-express" | ||
backendFolder="$ROOT/bfx-reports-framework" | ||
uiBuildFolder=/ui-build | ||
uiReadyFile="$uiBuildFolder/READY" | ||
|
||
rm -rf $frontendFolder | ||
rm -rf $backendFolder | ||
mkdir $frontendFolder | ||
mkdir $backendFolder | ||
mkdir $ROOT/dist 2>/dev/null | ||
chmod a+xwr $ROOT/dist 2>/dev/null | ||
|
||
git submodule foreach --recursive git clean -fdx | ||
git submodule foreach --recursive git reset --hard HEAD | ||
git submodule sync | ||
git submodule update --init --recursive | ||
git config url."https://github.com/".insteadOf [email protected]: | ||
git pull --recurse-submodules | ||
git submodule update --remote | ||
git submodule update --remote --recursive | ||
|
||
cd $frontendFolder | ||
if [ $isSkippedUIBuild == 0 ] | ||
then | ||
devFlag="" | ||
|
||
git submodule sync | ||
git submodule update --init --recursive | ||
git pull --recurse-submodules | ||
git submodule update --remote | ||
npm i | ||
|
||
sed -i -e "s/API_URL: .*,/API_URL: \'http:\/\/localhost:34343\/api\',/g" $frontendFolder/src/var/config.js | ||
sed -i -e "s/WS_ADDRESS: .*,/WS_ADDRESS: \'ws:\/\/localhost:34343\/ws\',/g" $frontendFolder/src/var/config.js | ||
echo "SKIP_PREFLIGHT_CHECK=true" >> $frontendFolder/.env | ||
if [ $isDevEnv == 0 ]; then | ||
devFlag="-d" | ||
fi | ||
|
||
if [ $isDevEnv != 0 ]; then | ||
sed -i -e "s/KEY_URL: .*,/KEY_URL: \'https:\/\/test.bitfinex.com\/api\',/g" $frontendFolder/src/var/config.js | ||
bash ./build-ui.sh $devFlag | ||
fi | ||
|
||
sed -i -e "s/showAuthPage: .*,/showAuthPage: true,/g" $frontendFolder/src/var/config.js | ||
sed -i -e "s/showSyncMode: .*,/showSyncMode: true,/g" $frontendFolder/src/var/config.js | ||
sed -i -e "s/showFrameworkMode: .*,/showFrameworkMode: true,/g" $frontendFolder/src/var/config.js | ||
npm run build | ||
|
||
cp $expressFolder/config/default.json.example $expressFolder/config/default.json | ||
|
||
cd $backendFolder | ||
|
@@ -93,5 +106,45 @@ fi | |
cd $ROOT | ||
|
||
if [ $isNotSkippedReiDeps != 0 ]; then | ||
bash ./reinstall-deps.sh | ||
if [ $targetPlatform != 0 ] | ||
then | ||
bash ./reinstall-deps.sh $targetPlatform | ||
|
||
if [ $isSkippedUIBuild != 0 ] | ||
then | ||
while !(test -f "$uiReadyFile"); do | ||
sleep 0.5 | ||
done | ||
fi | ||
|
||
mkdir $frontendFolder/build 2>/dev/null | ||
rm -rf $frontendFolder/build/* | ||
cp -avr $uiBuildFolder/* $frontendFolder/build | ||
chmod -R a+xwr $frontendFolder/build | ||
./node_modules/.bin/electron-builder build --$targetPlatform | ||
chmod -R a+xwr ./dist | ||
|
||
productName=$(getConfValue "productName") | ||
version=$(getConfValue "version") | ||
arch="x64" | ||
|
||
unpackedFolder=$(ls -d $ROOT/dist/*/ | grep $targetPlatform | head -1) | ||
zipFile="$ROOT/dist/$productName-$version-$arch-$targetPlatform.zip" | ||
|
||
if ! [ -d $unpackedFolder ]; then | ||
exit 1 | ||
fi | ||
|
||
cd $unpackedFolder | ||
7z a -tzip $zipFile . -mmt | grep -v "Compressing" | ||
cd $ROOT | ||
|
||
rm -rf /dist/*$targetPlatform* | ||
mv -f ./dist/*$targetPlatform*.zip /dist | ||
chmod -R a+xwr /dist 2>/dev/null | ||
|
||
exit 0 | ||
else | ||
bash ./reinstall-deps.sh | ||
fi | ||
fi |
Oops, something went wrong.