Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile #690

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 63 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,70 @@
FROM moelk/laravel
FROM php:7.3-apache

# Install cron
USER bitnami
RUN rm composer.lock
RUN sudo apt-get update && sudo apt-get install -y cron
RUN apt-get update

COPY --chown=bitnami:bitnami . /app
COPY --chown=bitnami:bitnami run.sh /app/run.sh
COPY --chown=bitnami:bitnami crontab /etc/cron.d/cool-task
RUN chmod 0644 /etc/cron.d/cool-task
RUN sudo chown bitnami:bitnami /var/log /etc/environment /var/run
# 1. development packages
RUN apt-get install -y \
git \
zip \
curl \
sudo \
unzip \
libicu-dev \
libbz2-dev \
libpng-dev \
libjpeg-dev \
libmcrypt-dev \
libreadline-dev \
libfreetype6-dev \
g++ \
nano

RUN crontab /etc/cron.d/cool-task
RUN touch /var/log/cron.log
RUN echo 'test' > /var/log/cron.log
RUN apt-get install -y zip libzip-dev \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip

RUN sudo service cron restart
ADD . /var/www/html/
# 2. apache configs + document root
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

# RUN sudo cron -f
# CMD ["sudo","cron","-f"]
# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers

# 4. start with base php config, then add extensions
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

RUN docker-php-ext-install \
bz2 \
intl \
iconv \
bcmath \
opcache \
calendar \
mbstring \
pdo_mysql \
zip \
gd

# 5. composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# 6. we need a user with the same UID/GID with host user
# so when we execute CLI commands, all the host file's ownership remains intact
# otherwise command from inside container will create root-owned files and directories
ARG uid
RUN useradd -G www-data,root -d /home/devuser devuser
RUN mkdir -p /home/devuser/.composer && \
chown -R devuser:devuser /home/devuser /var/www/html
WORKDIR /var/www/html
RUN chown -R www-data:www-data /var/www
RUN chgrp -R www-data storage/ && \
chmod -R g+rw storage/

RUN composer install

RUN sudo groupadd docker
RUN sudo usermod -aG docker devuser

EXPOSE 80