mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
✨ Improve build scripts.
This commit is contained in:
parent
7bd05d63ac
commit
6f0258c8d4
4 changed files with 90 additions and 75 deletions
|
@ -16,6 +16,6 @@ RUN set -ex; \
|
||||||
apt-get -qqy install adoptopenjdk-15-hotspot; \
|
apt-get -qqy install adoptopenjdk-15-hotspot; \
|
||||||
rm -rf /var/lib/apt/lists/*;
|
rm -rf /var/lib/apt/lists/*;
|
||||||
|
|
||||||
ADD ./bundle/backend/ /opt/bundle/
|
ADD ./bundle-app/backend/ /opt/bundle/
|
||||||
WORKDIR /opt/bundle
|
WORKDIR /opt/bundle
|
||||||
CMD ["/bin/bash", "run.sh"]
|
CMD ["/bin/bash", "run.sh"]
|
||||||
|
|
|
@ -83,7 +83,7 @@ RUN set -ex; \
|
||||||
|
|
||||||
WORKDIR /opt/app
|
WORKDIR /opt/app
|
||||||
|
|
||||||
ADD ./bundle/exporter/ /opt/app/
|
ADD ./bundle-exporter/ /opt/app/
|
||||||
|
|
||||||
RUN set -ex; \
|
RUN set -ex; \
|
||||||
export PATH="$PATH:/usr/local/nodejs/bin"; \
|
export PATH="$PATH:/usr/local/nodejs/bin"; \
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
FROM nginx:latest
|
FROM nginx:latest
|
||||||
LABEL maintainer="Andrey Antukh <niwi@niwi.nz>"
|
LABEL maintainer="Andrey Antukh <niwi@niwi.nz>"
|
||||||
|
|
||||||
ADD ./bundle/frontend /var/www/app/
|
ADD ./bundle-app/frontend /var/www/app/
|
||||||
|
ADD ./files/config.js /var/www/app/js/config.js
|
||||||
ADD ./files/nginx.conf /etc/nginx/nginx.conf
|
ADD ./files/nginx.conf /etc/nginx/nginx.conf
|
||||||
ADD ./files/nginx-entrypoint.sh /entrypoint.sh
|
ADD ./files/nginx-entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
|
158
manage.sh
158
manage.sh
|
@ -86,116 +86,126 @@ function build-backend {
|
||||||
build "backend";
|
build "backend";
|
||||||
}
|
}
|
||||||
|
|
||||||
function build-bundle {
|
function build-app-bundle {
|
||||||
local build_enabled=${PENPOT_BUNDLE_BUILD:-"true"};
|
local build_enabled=${PENPOT_BUNDLE_BUILD:-"true"};
|
||||||
|
local version="$CURRENT_VERSION";
|
||||||
|
local name="penpot-app-$CURRENT_BRANCH";
|
||||||
|
local bundle_dir="./bundle-app";
|
||||||
|
|
||||||
if [ $build_enabled == "true" ]; then
|
if [ $build_enabled == "true" ]; then
|
||||||
build "frontend";
|
build "frontend";
|
||||||
build "exporter";
|
|
||||||
build "backend";
|
build "backend";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf ./bundle
|
rm -rf $bundle_dir
|
||||||
mkdir -p ./bundle
|
mkdir -p $bundle_dir;
|
||||||
cp -r ./frontend/target/dist ./bundle/frontend
|
cp -r ./frontend/target/dist $bundle_dir/frontend;
|
||||||
cp -r ./backend/target/dist ./bundle/backend
|
cp -r ./backend/target/dist $bundle_dir/backend;
|
||||||
cp -r ./exporter/target ./bundle/exporter
|
|
||||||
|
|
||||||
local version="$CURRENT_VERSION";
|
|
||||||
local name="penpot-$CURRENT_BRANCH";
|
|
||||||
|
|
||||||
if [ $CURRENT_BRANCH != "main" ]; then
|
if [ $CURRENT_BRANCH != "main" ]; then
|
||||||
version="$CURRENT_BRANCH-$CURRENT_VERSION";
|
version="$CURRENT_BRANCH-$CURRENT_VERSION";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo $version > ./bundle/version.txt
|
echo $version > $bundle_dir/version.txt
|
||||||
|
|
||||||
sed -i -re "s/\%version\%/$version/g" ./bundle/frontend/index.html;
|
sed -i -re "s/\%version\%/$version/g" $bundle_dir/frontend/index.html;
|
||||||
sed -i -re "s/\%version\%/$version/g" ./bundle/backend/main/app/config.clj;
|
sed -i -re "s/\%version\%/$version/g" $bundle_dir/backend/main/app/config.clj;
|
||||||
|
}
|
||||||
|
|
||||||
local generate_tar=${PENPOT_BUNDLE_GENERATE_TAR:-"true"};
|
function build-exporter-bundle {
|
||||||
|
local build_enabled=${PENPOT_BUNDLE_BUILD:-"true"};
|
||||||
|
local version="$CURRENT_VERSION";
|
||||||
|
local name="penpot-exporter-$CURRENT_BRANCH";
|
||||||
|
local bundle_dir="./bundle-exporter";
|
||||||
|
|
||||||
if [ $generate_tar == "true" ]; then
|
if [ $build_enabled == "true" ]; then
|
||||||
pushd bundle/
|
build "exporter";
|
||||||
tar -I lz4 -cvf ../$name.tar.lz4 *;
|
|
||||||
popd
|
|
||||||
echo "##############################################################";
|
|
||||||
echo "# Generated $name.tar.lz4";
|
|
||||||
echo "# Version $version";
|
|
||||||
echo "##############################################################";
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -rf $bundle_dir;
|
||||||
|
cp -r ./exporter/target $bundle_dir;
|
||||||
|
|
||||||
|
if [ $CURRENT_BRANCH != "main" ]; then
|
||||||
|
version="$CURRENT_BRANCH-$CURRENT_VERSION";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
echo $version > $bundle_dir/version.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
function build-image {
|
function build-image {
|
||||||
local image=$1;
|
local image=$1;
|
||||||
local tag=$2;
|
local tag=$2;
|
||||||
local version=$3;
|
|
||||||
local docker_image="$ORGANIZATION/$image";
|
local docker_image="$ORGANIZATION/$image";
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
pushd ./docker/images;
|
pushd ./docker/images;
|
||||||
docker buildx build --platform linux/amd64 -t $docker_image:$tag -f Dockerfile.$image .;
|
docker buildx build --platform linux/amd64 -t $docker_image:$tag -f Dockerfile.$image .;
|
||||||
# docker tag $docker_image:$tag $docker_image:$version;
|
|
||||||
# docker buildx build --platform linux/arm64 -t $docker_image:$version-arm64 .;
|
|
||||||
popd;
|
popd;
|
||||||
}
|
}
|
||||||
|
|
||||||
function build-images {
|
function build-images {
|
||||||
local version="$CURRENT_VERSION";
|
local version="$CURRENT_VERSION";
|
||||||
local bundle_file="penpot-$CURRENT_BRANCH.tar.lz4";
|
local bundle_file="penpot-app-$CURRENT_BRANCH.tar.lz4";
|
||||||
|
local bundle_exporter_file="penpot-exporter-$CURRENT_BRANCH.tar.lz4";
|
||||||
if [ $CURRENT_BRANCH != "main" ]; then
|
|
||||||
version="$CURRENT_BRANCH-$CURRENT_VERSION";
|
|
||||||
bundle_file="penpot-$CURRENT_BRANCH.tar.lz4";
|
|
||||||
fi;
|
|
||||||
|
|
||||||
if [ ! -f $bundle_file ]; then
|
if [ ! -f $bundle_file ]; then
|
||||||
echo "File '$bundle_file' does not exists.";
|
echo "File '$bundle_file' does not exists.";
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $bundle_exporter_file ]; then
|
||||||
|
echo "File '$bundle_exporter_file' does not exists.";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
local bundle_file_path=`readlink -f $bundle_file`;
|
local bundle_file_path=`readlink -f $bundle_file`;
|
||||||
echo "Building docker image from: $bundle_file_path.";
|
local bundle_exporter_file_path=`readlink -f $bundle_exporter_file`;
|
||||||
|
|
||||||
rm -rf ./docker/images/bundle;
|
rm -rf ./docker/images/bundle-app;
|
||||||
mkdir -p ./docker/images/bundle;
|
rm -rf ./docker/images/bundle-exporter;
|
||||||
|
|
||||||
pushd ./docker/images/bundle;
|
mkdir -p ./docker/images/bundle-app;
|
||||||
|
mkdir -p ./docker/images/bundle-exporter;
|
||||||
|
|
||||||
|
pushd ./docker/images/bundle-app;
|
||||||
tar -I lz4 -xvf $bundle_file_path;
|
tar -I lz4 -xvf $bundle_file_path;
|
||||||
popd
|
popd
|
||||||
|
|
||||||
build-image "backend" $CURRENT_BRANCH $version;
|
pushd ./docker/images/bundle-exporter;
|
||||||
build-image "frontend" $CURRENT_BRANCH $version;
|
tar -I lz4 -xvf $bundle_exporter_file_path;
|
||||||
build-image "exporter" $CURRENT_BRANCH $version;
|
popd
|
||||||
|
|
||||||
|
build-image "backend" $CURRENT_BRANCH;
|
||||||
|
build-image "frontend" $CURRENT_BRANCH;
|
||||||
|
build-image "exporter" $CURRENT_BRANCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publish-latest-images {
|
# function publish-latest-images {
|
||||||
if [ $CURRENT_BRANCH != "main" ]; then
|
# if [ $CURRENT_BRANCH != "main" ]; then
|
||||||
echo "Latest image can only be build from main branch.";
|
# echo "Latest image can only be build from main branch.";
|
||||||
exit 1;
|
# exit 1;
|
||||||
fi;
|
# fi;
|
||||||
|
|
||||||
set -x
|
# set -x
|
||||||
|
|
||||||
docker tag $ORGANIZATION/frontend:$CURRENT_BRANCH $ORGANIZATION/frontend:latest;
|
# docker tag $ORGANIZATION/frontend:$CURRENT_BRANCH $ORGANIZATION/frontend:latest;
|
||||||
docker tag $ORGANIZATION/backend:$CURRENT_BRANCH $ORGANIZATION/backend:latest;
|
# docker tag $ORGANIZATION/backend:$CURRENT_BRANCH $ORGANIZATION/backend:latest;
|
||||||
docker tag $ORGANIZATION/exporter:$CURRENT_BRANCH $ORGANIZATION/exporter:latest;
|
# docker tag $ORGANIZATION/exporter:$CURRENT_BRANCH $ORGANIZATION/exporter:latest;
|
||||||
|
|
||||||
# docker push $ORGANIZATION/frontend:$CURRENT_VERSION;
|
# # docker push $ORGANIZATION/frontend:$CURRENT_VERSION;
|
||||||
# docker push $ORGANIZATION/backend:$CURRENT_VERSION;
|
# # docker push $ORGANIZATION/backend:$CURRENT_VERSION;
|
||||||
# docker push $ORGANIZATION/exporter:$CURRENT_VERSION;
|
# # docker push $ORGANIZATION/exporter:$CURRENT_VERSION;
|
||||||
docker push $ORGANIZATION/frontend:latest;
|
# docker push $ORGANIZATION/frontend:latest;
|
||||||
docker push $ORGANIZATION/backend:latest;
|
# docker push $ORGANIZATION/backend:latest;
|
||||||
docker push $ORGANIZATION/exporter:latest;
|
# docker push $ORGANIZATION/exporter:latest;
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
# function publish-snapshot-images {
|
||||||
function publish-snapshot-images {
|
# set -x
|
||||||
set -x
|
# docker push $ORGANIZATION/frontend:$CURRENT_BRANCH;
|
||||||
docker push $ORGANIZATION/frontend:$CURRENT_BRANCH;
|
# docker push $ORGANIZATION/backend:$CURRENT_BRANCH;
|
||||||
docker push $ORGANIZATION/backend:$CURRENT_BRANCH;
|
# docker push $ORGANIZATION/exporter:$CURRENT_BRANCH;
|
||||||
docker push $ORGANIZATION/exporter:$CURRENT_BRANCH;
|
# }
|
||||||
}
|
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
echo "PENPOT build & release manager"
|
echo "PENPOT build & release manager"
|
||||||
|
@ -260,19 +270,23 @@ case $1 in
|
||||||
|
|
||||||
# production builds
|
# production builds
|
||||||
build-frontend)
|
build-frontend)
|
||||||
build-frontend
|
build-frontend;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
build-backend)
|
build-backend)
|
||||||
build-backend
|
build-backend;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
build-exporter)
|
build-exporter)
|
||||||
build-exporter
|
build-exporter;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
build-bundle)
|
build-app-bundle)
|
||||||
build-bundle
|
build-app-bundle;
|
||||||
|
;;
|
||||||
|
|
||||||
|
build-exporter-bundle)
|
||||||
|
build-exporter-bundle;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Docker Image Tasks
|
# Docker Image Tasks
|
||||||
|
@ -280,13 +294,13 @@ case $1 in
|
||||||
build-images;
|
build-images;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
publish-snapshot-images)
|
# publish-snapshot-images)
|
||||||
publish-snapshot-images;
|
# publish-snapshot-images;
|
||||||
;;
|
# ;;
|
||||||
|
|
||||||
publish-latest-images)
|
# publish-latest-images)
|
||||||
publish-latest-images;
|
# publish-latest-images;
|
||||||
;;
|
# ;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
|
|
Loading…
Add table
Reference in a new issue