Created
November 16, 2021 13:31
-
-
Save ziedHamdi/87108daed2fc39f6e793f55e3f3d458a to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# GRAPHQL_SERVER_VERSION=$1 | |
# NEXT_SERVER_VERSION=$2 | |
# set variables from .env to system: https://gist.github.com/mihow/9c7f559807069a03e302605691f85572 | |
if [ -f .env ] | |
then | |
export $(cat .env | sed 's/#.*//g' | xargs) | |
fi | |
echo Building version $GRAPHQL_SERVER_VERSION of backend and version $NEXT_SERVER_VERSION of frontend | |
if [ -z $GRAPHQL_SERVER_VERSION ] | |
then | |
echo you didn''t specify the tag for the BACKEND git repository | |
exit | |
fi | |
if [ -z $NEXT_SERVER_VERSION ] | |
then | |
echo you didn''t specify the tag for the FRONTEND git repository | |
exit | |
fi | |
buildGraphQL="true" | |
buildNext="true" | |
# found here: https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash | |
while [[ "$#" -gt 0 ]]; do | |
case $1 in | |
-s|--skip) skip="$2"; | |
shift; | |
if [[ $skip == *"back"* ]]; then | |
buildGraphQL="false" | |
echo "skipping backend weallyback server build" | |
fi | |
if [[ $skip == *"front"* ]]; then | |
buildNext="false" | |
echo "skipping frontend weally.org server build" | |
fi | |
;; | |
*) echo "Unknown parameter passed: $1"; exit 1 ;; | |
esac | |
shift | |
done | |
cd .. # > prod/ | |
echo "building buildGraphQL: $buildGraphQL, buildNext: $buildNext" | |
if [ "$buildGraphQL" = "true" ] ; then | |
cd weallyback | |
git fetch | |
git reset --hard HEAD | |
git merge origin/$GRAPHQL_SERVER_VERSION | |
# > prod/weallyback/ | |
# sudo mkdir -p ./dist/server/public/images | |
# cp -a -rf --verbose ./server/public/images/. ./dist/server/public/images/. | |
echo building backend server | |
cd ../weally_conf | |
pwd | |
docker-compose run --rm graphql_server yarn install --production=false | |
docker-compose run --rm graphql_server yarn build | |
# docker build . -t graphql:$GRAPHQL_SERVER_VERSION | |
cd .. # > prod/ | |
fi | |
if [ "$buildNext" = "true" ] ; then | |
cd weally.org | |
git fetch | |
git reset --hard HEAD | |
git merge origin/$NEXT_SERVER_VERSION | |
cp -a -rf --verbose ../weally_conf/front/. . | |
# > prod/weally.org/ | |
echo building frontend server | |
cd ../weally_conf | |
pwd | |
docker-compose run --rm next_server yarn install --production=false | |
docker-compose run --rm next_server yarn build | |
# docker build . -t frontend:$NEXT_SERVER_VERSION | |
cd .. # > prod/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment