Created
April 20, 2019 15:21
-
-
Save defaultpage/2be12aa076fbff6720f499a832cee749 to your computer and use it in GitHub Desktop.
Revisions
-
defaultpage created this gist
Apr 20, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,92 @@ FROM php:7.1-fpm-alpine ### # ----------------------------------------------------------- # Configure system # ----------------------------------------------------------- ### # Update and install dependencies RUN apk add --update --quiet --no-cache bash \ busybox-suid \ bzip2-dev \ coreutils \ curl \ freetype-dev \ git \ libjpeg-turbo-dev \ libltdl \ libmcrypt-dev \ libpng-dev \ mysql-client \ openssh-client \ rsync \ yarn \ # Configure needed php extensions && docker-php-ext-configure mcrypt \ # Install needed php extensions && docker-php-ext-install mcrypt pdo_mysql zip gd \ # Install Composer && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ # Improve Composer performance with Prestissimo && composer global require hirak/prestissimo ### # ----------------------------------------------------------- # Define envinronments # ----------------------------------------------------------- ### # App arguments with default values ARG CRM_USER=crmsmuser ARG CRM_WWW=/home/${CRM_USER}/www # App arguments as an envinronments ENV CRM_USER ${CRM_USER} ENV CRM_WWW ${CRM_WWW} # Define build envinronments ENV BIN /usr/local/bin/ ENV INIT_SCRIPT_PATH ${CRM_WWW}/ci-cd/crm/init.sh ENV SETUP_SCRIPT_PATH ${CRM_WWW}/ci-cd/crm/setup.sh ### # ----------------------------------------------------------- # Configure build # ----------------------------------------------------------- ### # Copy and set entrypoint script COPY /ci-cd/container-entrypoint.sh ${BIN}/container-entrypoint RUN chmod +x ${BIN}/container-entrypoint ENTRYPOINT ["container-entrypoint"] # Set default command CMD ["php-fpm"] ### # ----------------------------------------------------------- # Configure system for app # ----------------------------------------------------------- ### # Add user and group RUN addgroup -g 1000 -S ${CRM_USER} && adduser -u 1000 -S ${CRM_USER} -G ${CRM_USER} # Change user USER ${CRM_USER} # Attach project files VOLUME /* ${CRM_WWW} # Change work dir to project dir WORKDIR ${CRM_WWW} ### # ----------------------------------------------------------- # Configure app # ----------------------------------------------------------- ### # ... This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ #!/bin/bash set -e set -a INIT_SCRIPT_PATH=${INIT_SCRIPT_PATH} SETUP_SCRIPT_PATH=${SETUP_SCRIPT_PATH} SETUP_LOCK_PATH=~/.container-configured.lock # ... # Here put all the variables that will be marked for export # and that will be available from all commands. # If command modifies the variables, the modifications will never be # seen in the present script! set +a echo "Entrypoint..." # If lock file don't exists, setup script exists if [[ ! -f ${SETUP_LOCK_PATH} && -f ${SETUP_SCRIPT_PATH} ]]; then # Run setup echo 'Running one-time setup...' source ${SETUP_SCRIPT_PATH} "$@" # Create lock file touch ${SETUP_LOCK_PATH} fi # If init script exists if [[ -f ${INIT_SCRIPT_PATH} ]]; then # Run init echo 'Running init...' source ${INIT_SCRIPT_PATH} "$@" fi # Run docker command exec "$@"