-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
183 additions
and
72 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
FROM php:7.3.8-fpm-alpine3.10 | ||
FROM php:7.4.10-fpm-alpine3.11 | ||
|
||
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" \ | ||
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \ | ||
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \ | ||
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" \ | ||
PHP_MEMORY_LIMIT="512M" | ||
PHP_MEMORY_LIMIT="512M" \ | ||
PHP_MAX_EXECUTION_TIME="60" \ | ||
PHP_FPM_MAX_CHILDREN="100" \ | ||
PHP_FPM_MAX_REQUESTS="1000" \ | ||
PHP_FPM_PM="ondemand" \ | ||
PHP_FPM_PROCESS_IDLE_TIMEOUT="10s" | ||
|
||
RUN apk info \ | ||
&& echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \ | ||
&& echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \ | ||
&& echo @3.9 http://dl-cdn.alpinelinux.org/alpine/v3.9/main >> /etc/apk/repositories \ | ||
&& apk update \ | ||
&& apk upgrade \ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
|
@@ -36,10 +40,7 @@ RUN apk info \ | |
php7-dom \ | ||
mysql-client \ | ||
yarn@edge \ | ||
xvfb \ | ||
[email protected] \ | ||
[email protected] \ | ||
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-png-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ | ||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | ||
&& docker-php-ext-install -j$(nproc) \ | ||
gd \ | ||
pdo_mysql \ | ||
|
@@ -49,7 +50,6 @@ RUN apk info \ | |
intl \ | ||
opcache \ | ||
pcntl \ | ||
mbstring \ | ||
iconv \ | ||
&& pecl install \ | ||
redis \ | ||
|
@@ -66,11 +66,6 @@ ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php | |
# change default shell | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
# create app user | ||
RUN addgroup -S app && \ | ||
adduser -S app -G app && \ | ||
echo "app ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
# create working dir | ||
RUN mkdir /opt/app | ||
WORKDIR /opt/app | ||
|
@@ -90,6 +85,9 @@ COPY ./etc/nginx/ /etc/nginx/ | |
COPY ./usr/local/etc/php/ /usr/local/etc/php/ | ||
COPY ./usr/local/etc/php-fpm.d/ /usr/local/etc/php-fpm.d/ | ||
|
||
# copy bin files | ||
COPY ./usr/local/bin/startup-commands.php /usr/local/bin/ | ||
|
||
# configure composer | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 \ | ||
COMPOSER_MEMORY_LIMIT=-1 | ||
|
@@ -100,11 +98,11 @@ RUN composer global require hirak/prestissimo | |
RUN yarn config set strict-ssl false && \ | ||
yarn global add cross-env | ||
|
||
# copy home folder and make run scripts executable | ||
COPY ./home/app/ /home/app/ | ||
COPY ./root/.bashrc /root/ | ||
RUN find /home/app -name "run-*.sh" -exec chmod -v +x {} \; | ||
# copy root folder and make run scripts executable | ||
COPY ./root/ /root/ | ||
RUN find /root -name "*.sh" -exec chmod -v +x {} \; | ||
|
||
# run the application | ||
CMD /home/app/run-dev.sh | ||
ENTRYPOINT ["/root/entrypoint.sh"] | ||
CMD ["runsvdir", "/etc/service"] | ||
EXPOSE 8080 |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
source /home/app/.bashrc | ||
# useful aliases | ||
alias ll='ls -la' | ||
alias artisan="php artisan" | ||
|
||
# prompt colors and short user display | ||
force_color_prompt=yes | ||
PS1='\[\033[1;36m\]\u\[\033[1;31m\]\[\033[1;32m\]:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] ' | ||
|
||
# artisan autocompletion | ||
_artisan() | ||
{ | ||
COMP_WORDBREAKS=${COMP_WORDBREAKS//:} | ||
COMMANDS=`artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"` | ||
COMPREPLY=(`compgen -W "$COMMANDS" -- "${COMP_WORDS[COMP_CWORD]}"`) | ||
return 0 | ||
} | ||
complete -F _artisan artisan |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
echo "Running entrypoint script..." | ||
|
||
set -e | ||
|
||
# make sure Laravel can write its own files | ||
mkdir -p /opt/app/storage/logs/ | ||
touch /opt/app/storage/logs/laravel.log | ||
touch /opt/app/storage/logs/worker.log | ||
chown www-data:www-data -R /opt/app/storage | ||
chown www-data:www-data -R /opt/app/bootstrap/cache | ||
|
||
# startup commands | ||
echo "Running startup commands..." | ||
php /usr/local/bin/startup-commands.php | bash | ||
|
||
if [[ -n "$DB_HOST" || -n "$DB_PORT" ]]; then | ||
wait-for-it.sh --host=$DB_HOST --port=$DB_PORT | ||
fi | ||
|
||
exec "$@" |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd /opt/app | ||
|
||
# build caches | ||
echo "Build caches..." | ||
php artisan config:cache | ||
php artisan route:cache | ||
php artisan view:cache |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
cd /opt/app | ||
|
||
echo "Build development..." | ||
composer install --prefer-dist --no-progress --no-interaction | ||
yarn |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
cd /opt/app | ||
|
||
echo "Create storage symlink..." | ||
su www-data -s /bin/sh -c "php artisan storage:link -q" |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* A very simple script in charge of generating the startup commands based on environment variables. | ||
* The script is run on each start of the container. | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2018 TheCodingMachine | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
$commands = array_filter($_SERVER, function(string $key) { | ||
return strpos($key, 'STARTUP_COMMAND') === 0; | ||
}, ARRAY_FILTER_USE_KEY); | ||
|
||
ksort($commands); | ||
|
||
echo "set -e\n"; | ||
|
||
|
||
// Let's run the commands as user $UID if env variable UID is set. | ||
|
||
foreach ($commands as $command) { | ||
$line = $command; | ||
if (isset($_SERVER['UID'])) { | ||
$line = 'sudo -E -u \\#'.$_SERVER['UID'].' bash -c '.escapeshellarg($line); | ||
} | ||
echo $line."\n"; | ||
} |
This file contains 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 characters
This file contains 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 characters