Files
opensem/docker/workspace/Dockerfile
Ludovic CANDELLIER bc7880b242 add docker version
2023-09-13 23:04:55 +02:00

181 lines
5.7 KiB
Docker

FROM debian:stable-slim
# FROM bitnami/minideb:latest
LABEL maintainer="Ludovic CANDELLIER <ludo@huma.net>"
# Set Environment Variables
ENV DEBIAN_FRONTEND noninteractive
# Start as root
USER root
###########################################################################
# Laradock non-root user:
###########################################################################
# Add a non-root user to prevent files being created with root permissions on host machine.
ARG PUID=1000
ENV PUID ${PUID}
ARG PGID=1000
ENV PGID ${PGID}
RUN groupadd -g ${PGID} laradock; \
useradd -l -u ${PUID} -g laradock -m laradock; \
usermod -p "*" laradock -s /bin/bash;
# always run apt update when start and after add new source list, then clean up at end.
RUN apt-get update -yqq; \
apt-get upgrade -yqq; \
apt-get -yqq install --no-install-recommends apt-transport-https lsb-release tzdata ca-certificates curl wget \
apt-utils libzip-dev joe zip unzip rsync openssh-client git mc bzip2 nano default-mysql-client supervisor inetutils-ping mydumper \
wkhtmltopdf ghostscript jpegoptim optipng pngquant gifsicle chromium chromium-sandbox
COPY ./apt_sources/php.list /etc/apt/sources.list.d/php.list
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg;
RUN apt-get update -yqq; \
apt install -yqq --no-install-recommends php8.0-apcu php8.0-bcmath php8.0-bz2 php8.0-cli php8.0-common php8.0-curl php8.0-dev php8.0-gd php8.0-igbinary php8.0-imagick \
php8.0-intl php8.0-mbstring php8.0-mcrypt php8.0-mysql php8.0-opcache php8.0-readline php8.0-redis php8.0-sqlite3 php8.0-tidy php8.0-uuid php8.0-xml php8.0-yaml php8.0-zip
RUN apt-get install -yqq --no-install-recommends nodejs npm python2
RUN update-alternatives --install /usr/bin/python python /usr/bin/python2 1
###########################################################################
# Set Timezone
###########################################################################
ARG TZ=UTC
ENV TZ ${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
###########################################################################
# Composer:
###########################################################################
USER root
# Install composer and add its bin to the PATH.
RUN curl -s http://getcomposer.org/installer | php \
&& echo "export PATH=${PATH}:/var/www/vendor/bin" >> ~/.bashrc \
&& mv composer.phar /usr/local/bin/composer
# Export composer vendor path
RUN echo "" >> ~/.bashrc && \
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
# Update composer
ARG COMPOSER_VERSION=2
ENV COMPOSER_VERSION ${COMPOSER_VERSION}
RUN set -eux; \
if [ "$COMPOSER_VERSION" = "1" ] || [ "$COMPOSER_VERSION" = "2" ]; then \
composer self-update --${COMPOSER_VERSION}; \
else \
composer self-update ${COMPOSER_VERSION}; \
fi
USER laradock
# Export composer vendor path
RUN echo "" >> ~/.bashrc && \
echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc
###########################################################################
# Non-root user : PHPUnit path
###########################################################################
# add ./vendor/bin to non-root user's bashrc (needed for phpunit)
USER laradock
RUN echo "" >> ~/.bashrc && \
echo 'export PATH="/var/www/vendor/bin:$PATH"' >> ~/.bashrc
###########################################################################
# Crontab
###########################################################################
USER root
COPY ./crontab /etc/cron.d
RUN chmod -R 644 /etc/cron.d
###########################################################################
# YARN:
###########################################################################
USER laradock
RUN curl -o- -L https://yarnpkg.com/install.sh | bash; \
echo "" >> ~/.bashrc && \
echo 'export PATH="$HOME/.yarn/bin:$PATH"' >> ~/.bashrc
# Add YARN binaries to root's .bashrc
USER root
RUN echo "" >> ~/.bashrc && \
echo 'export YARN_DIR="/home/laradock/.yarn"' >> ~/.bashrc && \
echo 'export PATH="$YARN_DIR/bin:$PATH"' >> ~/.bashrc
# Add PATH for YARN
ENV PATH $PATH:/home/laradock/.yarn/bin
RUN npm install -g grunt-cli
###########################################################################
# SUPERVISOR:
###########################################################################
ARG INSTALL_SUPERVISOR=false
RUN if [ ${INSTALL_SUPERVISOR} = true ]; then \
if [ ${INSTALL_PYTHON} = true ]; then \
python -m pip install --upgrade supervisor && \
echo_supervisord_conf > /etc/supervisord.conf && \
sed -i 's/\;\[include\]/\[include\]/g' /etc/supervisord.conf && \
sed -i 's/\;files\s.*/files = supervisord.d\/*.conf/g' /etc/supervisord.conf \
;fi \
;fi
###########################################################################
# GIT:
###########################################################################
# RUN git --global config pull.ff only
###########################################################################
# PM2:
###########################################################################
RUN npm install -g pm2
###########################################################################
# Check PHP version:
###########################################################################
RUN set -xe; php -v | head -n 1 | grep -q "PHP 8.0."
#
#--------------------------------------------------------------------------
# Final Touch
#--------------------------------------------------------------------------
#
USER root
# Clean up
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
rm /var/log/lastlog /var/log/faillog
# COPY ./supervisord/* /etc/supervisor/conf.d/
# Set default work directory
WORKDIR /var/www
USER laradock