dotfiles/home/bin/executable_pack-magneto2-source
2025-05-15 11:22:56 +08:00

26 lines
711 B
Bash

#!/usr/bin/env bash
set -xe
# usage: pack-magneto2-source <image repo> [output folder]
if [ $# -lt 1 ]; then
echo "Usage: $0 <image repo> [output folder]"
exit 1
fi
IMAGE_REPO=$1
OUTPUT_FOLDER=$(realpath "${2:-.}")
# echo "Packing Magento 2 source code from $IMAGE_REPO to $OUTPUT_FOLDER"
uid=$(id -u)
docker run -it --rm -v "$OUTPUT_FOLDER:/out" -e "HOST_UID=$uid" \
"$IMAGE_REPO" \
bash -c 'cd /app && \
find /app -type f -iname "*test*" -exec rm -f {} \; && \
rm -rf /app/node_modules && \
rm -rf /app/system/modules/swagger/public/swagger-ui/* && \
chown -R $HOST_UID /app && \
tar -cvf /out/magneto2.tar . && \
chown $HOST_UID /out/magneto2.tar'
# vim : set ft=sh :