Skip to content

Commit

Permalink
Merge branch '1.7' into merge-17-20
Browse files Browse the repository at this point in the history
  • Loading branch information
pierallard committed Feb 16, 2018
2 parents 0702952 + c19d162 commit 9c04f14
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 54 deletions.
103 changes: 66 additions & 37 deletions Dockerfile
@@ -1,54 +1,83 @@
FROM debian:9-slim AS pim
MAINTAINER pierre.allard@akeneo.com
WORKDIR /home/akeneo/pim-docs/

# Sphinx installation
RUN apt-get update && \
apt-get install -y python-pip git
RUN pip install --upgrade pip
RUN pip install sphinx~=1.5.3 && \
pip install git+https://github.com/fabpot/sphinx-php.git && \
pip install git+https://github.com/mickaelandrieu/sphinxcontrib.youtube.git
RUN apt-get clean && apt-get --yes --quiet autoremove --purge && \
rm -rf /var/lib/apt/lists/*

# Akeneo PIM installation
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y wget unzip

# Install mysql-server
RUN apt-get install -y lsb-release apt-transport-https ca-certificates && \
# Create environment for build with php, python, mysql and composer
RUN apt-get update && \
apt-get install -y --no-install-recommends wget lsb-release apt-transport-https ca-certificates gnupg unzip \
python python-setuptools ssh rsync && \
#
# Add source for mysql
wget -O /tmp/mysql-apt-config.deb https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb && \
dpkg -i /tmp/mysql-apt-config.deb && \
apt-get update && \
apt-get install -y mysql-server && \
rm /tmp/mysql-apt-config.deb

# Install php
RUN apt-get install -y apt-transport-https ca-certificates && \
#
# Add source for php
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
sh -c 'echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/php.list' && \
apt update && \
apt-get install -y php7.1-apcu php7.1-bcmath php7.1-cli php7.1-curl php7.1-fpm php7.1-gd php7.1-intl php7.1-mcrypt php7.1-mysql php7.1-soap php7.1-xml php7.1-zip php7.1-mbstring && \
#
# Add sphinx
wget -O /tmp/sphinx.zip https://github.com/sphinx-doc/sphinx/archive/v1.5.6.zip && \
unzip /tmp/sphinx.zip -d /tmp/ && \
cd /tmp/sphinx-1.5.6/ && \
python setup.py install && \
#
# Add youtube-sphinx extension
wget -O /tmp/sphinxcontrib.youtube.zip \
https://github.com/mickaelandrieu/sphinxcontrib.youtube/archive/master.zip && \
unzip /tmp/sphinxcontrib.youtube.zip -d /tmp/ && \
cd /tmp/sphinxcontrib.youtube-master/ && \
python setup.py install && \
#
# Add sphinx-php extension
wget -O /tmp/sphinx-php.zip \
https://github.com/fabpot/sphinx-php/archive/v1.0.10.zip && \
unzip /tmp/sphinx-php.zip -d /tmp/ && \
cd /tmp/sphinx-php-1.0.10/ && \
python setup.py install && \
#
# Download packages
apt-get update && \
apt-get install -y --no-install-recommends mysql-server php7.1-apcu php7.1-bcmath \
php7.1-cli php7.1-curl php7.1-fpm php7.1-gd php7.1-intl php7.1-mcrypt php7.1-mysql php7.1-soap php7.1-xml \
php7.1-zip php7.1-mbstring && \
#
# Configure PHP
echo "memory_limit = 1024M" >> /etc/php/7.1/cli/php.ini && \
echo "date.timezone = Etc/UTC" >> /etc/php/7.1/cli/php.ini
echo "date.timezone = Etc/UTC" >> /etc/php/7.1/cli/php.ini && \
#
# Get composer
wget https://getcomposer.org/download/1.6.2/composer.phar -P /home/akeneo/pim-docs/ && \
#
# Clean
apt-get clean && apt-get --yes --quiet autoremove --purge && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf /usr/share/doc/* && \
rm -rf /usr/share/man/* && \
rm -rf /usr/share/locale/* && \
rm -rf /var/log/*

# Purge apt
RUN apt-get clean && apt-get --yes --quiet autoremove --purge && \
rm -rf /var/lib/apt/lists/*
COPY build.sh /home/akeneo/pim-docs/build.sh

# Compute assets
RUN wget https://github.com/akeneo/pim-community-dev/archive/2.0.zip -P /home/akeneo/pim-docs/ && \
# Install Akeneo PIM Assets
RUN chmod +x /home/akeneo/pim-docs/build.sh && \
#
# Download curent version
wget https://github.com/akeneo/pim-community-dev/archive/2.0.zip -P /home/akeneo/pim-docs/ && \
unzip /home/akeneo/pim-docs/2.0.zip -d /home/akeneo/pim-docs/ && \
wget https://getcomposer.org/download/1.6.2/composer.phar -P /home/akeneo/pim-docs/ && \
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && php -d memory_limit=3G ../composer.phar install --no-dev --no-suggest --ignore-platform-reqs && \
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && \
#
# Install Akeneo PIM
php -d memory_limit=3G /home/akeneo/pim-docs/composer.phar install --no-dev --no-suggest --ignore-platform-reqs && \
service mysql start && \
mysql -u root -e "CREATE DATABASE akeneo_pim" && \
mysql -u root -e "GRANT ALL PRIVILEGES ON akeneo_pim.* TO akeneo_pim@localhost IDENTIFIED BY 'akeneo_pim'" && \
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && php bin/console doctrine:schema:create --env=prod && \
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && php bin/console pim:installer:assets --env=prod

# Copy script
COPY build.sh /home/akeneo/pim-docs/build.sh
RUN chmod +x /home/akeneo/pim-docs/build.sh
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && php bin/console pim:installer:assets --env=prod && \
service mysql stop && \
#
# Clean
rm -rf /root/.composer/cache && \
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && ls | grep -v "vendor\|web" | xargs rm -rf && \
rm /var/lib/mysql/ibdata1 /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile0
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -94,7 +94,7 @@ From the `./pim-docs` directory, run:
$ docker run --rm \
-v $(pwd):/home/akeneo/pim-docs/data \
pim-docs:2.0 \
./build.sh --uid $(id -u) --gid $(id -g)
./build.sh 2.0 --uid $(id -u) --gid $(id -g) --no-asset-check
```

The docs will be built into `./pim-docs-build`.
34 changes: 18 additions & 16 deletions build.sh
@@ -1,7 +1,8 @@
#!/bin/bash -e

usage(){
echo "Usage: $0 [--uid <uid>] [--gid <gid>] [--no-asset-check] [--deploy --host <host> --port <port> --username <username>]"
echo "Usage: $0 <version> [--uid <uid>] [--gid <gid] [ [--no-asset-check] [--deploy --host <host> --port <port> --username <username>]"
echo " version The version to build (e.g. 1.7 or master)"
echo " --deploy Deploy to the server"
echo " --no-asset-check Do not check asset changes"
echo " --host <host> Host used for deployment"
Expand All @@ -18,6 +19,7 @@ PORT=22
USERNAME=pim-docs
CUSTOM_UID=`id -u`
CUSTOM_GID=`id -g`
VERSION=$1; shift; echo "Building version $VERSION..."

while true; do
case "$1" in
Expand All @@ -43,36 +45,36 @@ if [ "$DEPLOY" == true ]; then
fi

if [ "$ASSET_CHECK" != false ]; then
wget https://github.com/akeneo/pim-community-dev/archive/2.0.zip -P /tmp/
echo "Checking for asset modifications. To avoid this step, use --no-asset-check"
wget https://github.com/akeneo/pim-community-dev/archive/${VERSION}.zip -P /tmp/

md5original=`md5sum /home/akeneo/pim-docs/2.0.zip | cut -f 1 -d " "`
md5current=`md5sum /tmp/2.0.zip | cut -f 1 -d " "`
md5original=`md5sum /home/akeneo/pim-docs/${VERSION}.zip | cut -f 1 -d " "`
md5current=`md5sum /tmp/${VERSION}.zip | cut -f 1 -d " "`

if [ "$md5original" = "$md5current" ]
then
echo "Akeneo PIM does not change."
rm /tmp/2.0.zip
rm /tmp/${VERSION}.zip
else
echo "Rebuild Akeneo PIM assets..."
rm -rf /home/akeneo/pim-docs/2.0.zip
mv /tmp/2.0.zip /home/akeneo/pim-docs/2.0.zip
rm -rf /home/akeneo/pim-docs/pim-community-dev-2.0
unzip /home/akeneo/pim-docs/2.0.zip -d /home/akeneo/pim-docs/
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && php -d memory_limit=3G ../composer.phar install --no-dev --no-suggest
rm -rf /home/akeneo/pim-docs/${VERSION}.zip
mv /tmp/${VERSION}.zip /home/akeneo/pim-docs/${VERSION}.zip
rm -rf /home/akeneo/pim-docs/pim-community-dev-${VERSION}
unzip /home/akeneo/pim-docs/${VERSION}.zip -d /home/akeneo/pim-docs/
cd /home/akeneo/pim-docs/pim-community-dev-${VERSION}/ && php -d memory_limit=3G ../composer.phar install --no-dev --no-suggest --ignore-platform-reqs
service mysql start && \
cd /home/akeneo/pim-docs/pim-community-dev-2.0/ && php bin/console pim:installer:assets --env=prod
cd /home/akeneo/pim-docs/pim-community-dev-${VERSION}/ && php bin/console pim:installer:assets --env=prod
fi
fi

rm -rf /home/akeneo/pim-docs/data/pim-docs-build/web
rm -rf /home/akeneo/pim-docs/data/pim-docs-build/vendor
sed -i -e "s/^version =.*/version = '2.0'/" /home/akeneo/pim-docs/data/conf.py
sed -i -e "s/^version =.*/version = '${VERSION}'/" /home/akeneo/pim-docs/data/conf.py
sphinx-build -b html /home/akeneo/pim-docs/data /home/akeneo/pim-docs/data/pim-docs-build
cp -r /home/akeneo/pim-docs/pim-community-dev-2.0/web /home/akeneo/pim-docs/data/pim-docs-build/
cp -r /home/akeneo/pim-docs/pim-community-dev-2.0/vendor /home/akeneo/pim-docs/data/pim-docs-build/
cp -L -r /home/akeneo/pim-docs/pim-community-dev-${VERSION}/web /home/akeneo/pim-docs/data/pim-docs-build/
cp -L -r /home/akeneo/pim-docs/pim-community-dev-${VERSION}/vendor /home/akeneo/pim-docs/data/pim-docs-build/
cp -r /home/akeneo/pim-docs/data/design_pim/styleguide /home/akeneo/pim-docs/data/pim-docs-build/design_pim/
find /home/akeneo/pim-docs/data/pim-docs-build/ -exec chown $CUSTOM_UID:$CUSTOM_GID {} \;

if [ "$DEPLOY" == true ]; then
rsync -e "ssh -p $PORT" -avz /home/akeneo/pim-docs/data/pim-docs-build/* $USERNAME@$HOST:/var/www/2.0
rsync -e "ssh -p $PORT" -avz /home/akeneo/pim-docs/data/pim-docs-build/* $USERNAME@$HOST:/var/www/${VERSION}
fi

0 comments on commit 9c04f14

Please sign in to comment.