-
Notifications
You must be signed in to change notification settings - Fork 2
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
a dockerfile & docker-compose #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
ARG PHP_VERSION=7.3 | ||
|
||
FROM php:${PHP_VERSION}-cli-alpine AS php | ||
|
||
ARG GID=1000 | ||
ARG UID=1000 | ||
ARG APP_ENV=dev | ||
|
||
# Prevent Symfony Flex from generating a project ID at build time | ||
ARG SYMFONY_SKIP_REGISTRATION=1 | ||
|
||
ENV APP_ENV=${APP_ENV} | ||
ENV APP_PATH=/var/www/app | ||
|
||
RUN apk add --no-cache \ | ||
acl \ | ||
file \ | ||
gettext \ | ||
sqlite \ | ||
sqlite-dev \ | ||
unzip \ | ||
git \ | ||
bash \ | ||
; | ||
|
||
ARG APCU_VERSION=5.1.12 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be dropped |
||
RUN set -eux; \ | ||
apk add --no-cache --virtual .build-deps \ | ||
$PHPIZE_DEPS \ | ||
icu-dev \ | ||
libzip-dev \ | ||
zlib-dev \ | ||
; | ||
|
||
RUN docker-php-ext-configure zip --with-libzip; \ | ||
docker-php-ext-install -j$(nproc) \ | ||
intl \ | ||
pdo_sqlite \ | ||
zip \ | ||
; \ | ||
pecl install \ | ||
apcu-${APCU_VERSION} \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be dropped |
||
; \ | ||
pecl clear-cache; | ||
RUN docker-php-ext-enable \ | ||
apcu \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be dropped |
||
opcache \ | ||
pdo_sqlite \ | ||
; \ | ||
\ | ||
runDeps="$( \ | ||
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhhh, what the heck is going on here? (generally unfamiliar with all this) |
||
| tr ',' '\n' \ | ||
| sort -u \ | ||
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ | ||
)"; \ | ||
apk add --no-cache --virtual .api-phpexts-rundeps $runDeps; \ | ||
\ | ||
apk del .build-deps | ||
|
||
|
||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
COPY docker/php.ini /usr/local/etc/php/php.ini | ||
|
||
# Install Composer globally | ||
ENV COMPOSER_ALLOW_SUPERUSER 1 | ||
|
||
RUN set -eux; \ | ||
composer global require "symfony/flex" --prefer-dist --no-progress --no-suggest --classmap-authoritative; | ||
ENV PATH="${PATH}:/root/.composer/vendor/bin:./vendor/bin" | ||
|
||
WORKDIR ${APP_PATH} | ||
|
||
COPY composer.json composer.lock ./ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This project has no deployment/build target: having just the volume mounted, and |
||
# prevent the reinstallation of vendors at every changes in the source code | ||
RUN set -eux; \ | ||
composer install --prefer-dist --no-autoloader --no-scripts --no-progress --no-suggest; \ | ||
composer clear-cache | ||
|
||
COPY . ./ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above: container should be configured for dev purposes only: all blocks performing |
||
|
||
RUN set -eux; \ | ||
mkdir -p var/cache var/log; \ | ||
composer dump-autoload --classmap-authoritative; \ | ||
composer run-script post-install-cmd; | ||
|
||
RUN egrep -i ":$GID:" /etc/passwd &>/dev/null || addgroup -S --gid "$GID" appgroup | ||
RUN egrep -i ":$UID:" /etc/passwd &>/dev/null || adduser -S appuser -G appgroup \ | ||
--uid "$UID" \ | ||
--disabled-password | ||
|
||
RUN chown -R $UID:$GID ${APP_PATH}; \ | ||
chown -R $UID:$GID ${APP_PATH}/var; \ | ||
chmod +x bin/console; sync | ||
|
||
#VOLUME ${APP_PATH} | ||
USER $UID:$GID | ||
|
||
EXPOSE 8080 | ||
CMD ["/var/www/app/run.sh"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: "3.4" | ||
services: | ||
php: | ||
#image: php:sflive | ||
build: | ||
context: . | ||
ports: | ||
- "7811:8080" | ||
dns: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably to be dropped - host DNS resolution should suffice |
||
- 10.240.0.100 | ||
- 10.240.0.200 | ||
volumes: | ||
- ./:/var/www/app:rw,cached |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[core] | ||
date.timezone = UTC | ||
session.auto_start = Off | ||
short_open_tag = Off | ||
realpath_cache_size = 4096K | ||
realpath_cache_ttl = 600 | ||
|
||
[opcache] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opcache not really needed in the scope of this project |
||
opcache.enable_file_override = On | ||
opcache.interned_strings_buffer = 16 | ||
opcache.max_accelerated_files = 20000 | ||
opcache.memory_consumption = 256 | ||
#opcache.revalidate_freq = 2 | ||
opcache.validate_timestamps = On |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
php -S localhost:8080 -t public | ||
php -S 0.0.0.0:8080 -t public |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No flex in this project, luckily :)