Skip to content

Commit

Permalink
Refactor Dockerile (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
ucan-lab authored Dec 8, 2023
1 parent 5943b8c commit 7a03e88
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
**.editorconfig
**.gitattributes
**.gitignore
**.md
8 changes: 5 additions & 3 deletions infra/docker/mysql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM mysql/mysql-server:8.0

ENV TZ=UTC

RUN mkdir /var/log/mysql \
&& chown mysql:mysql $_ \
&& chmod 777 $_
RUN <<EOF
mkdir /var/log/mysql
chown mysql:mysql $_
chmod 777 $_
EOF
50 changes: 29 additions & 21 deletions infra/docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,43 @@ ENV TZ=UTC \

COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer

RUN apt-get update \
&& apt-get -y install --no-install-recommends \
RUN <<EOF
apt-get update
apt-get -y install --no-install-recommends \
locales \
git \
unzip \
libzip-dev \
libicu-dev \
libonig-dev \
&& locale-gen en_US.UTF-8 \
&& localedef -f UTF-8 -i en_US en_US.UTF-8 \
&& docker-php-ext-install \
libonig-dev
locale-gen en_US.UTF-8
localedef -f UTF-8 -i en_US en_US.UTF-8
docker-php-ext-install \
intl \
pdo_mysql \
zip \
bcmath \
&& composer config -g process-timeout 3600 \
&& composer config -g repos.packagist composer https://packagist.org
bcmath
composer config -g process-timeout 3600
composer config -g repos.packagist composer https://packagist.org
EOF

FROM base AS development

RUN apt-get -y install --no-install-recommends \
default-mysql-client \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN <<EOF
apt-get -y install --no-install-recommends \
default-mysql-client
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

COPY ./infra/docker/php/php.development.ini /usr/local/etc/php/php.ini

FROM development AS development-xdebug

RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
RUN <<EOF
pecl install xdebug
docker-php-ext-enable xdebug
EOF

COPY ./infra/docker/php/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini

Expand All @@ -53,9 +59,11 @@ FROM base AS deploy
COPY ./infra/docker/php/php.deploy.ini /usr/local/etc/php/php.ini
COPY ./src /workspace

RUN composer install -q -n --no-ansi --no-dev --no-scripts --no-progress --prefer-dist \
&& chmod -R 777 storage bootstrap/cache \
&& php artisan optimize:clear \
&& php artisan optimize \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN <<EOF
composer install -q -n --no-ansi --no-dev --no-scripts --no-progress --prefer-dist
chmod -R 777 storage bootstrap/cache
php artisan optimize:clear
php artisan optimize
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

0 comments on commit 7a03e88

Please sign in to comment.