-
Notifications
You must be signed in to change notification settings - Fork 331
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
Add Docker setup #232
Closed
Closed
Add Docker setup #232
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5ccee36
Require Sylius v1.3.x@dev
pamil 33e669d
Merge branch '1.2'
pamil 227028a
Merge branch '1.2'
pamil 34cffaf
Update composer lockfile
pamil 7a68f28
Fix composer.json requirements
pamil 2a8b93a
Merge branch '1.2'
pamil 37d6ef9
Upgrade Composer & Yarn dependencies
pamil c93682c
Merge branch '1.2'
pamil fbb0750
Update to Sylius v1.3.0@dev
pamil f091c6d
Merge branch '1.2'
pamil 5b90e85
Add Docker setup
teohhanhui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
**/*.log | ||
**/*.md | ||
**/*.php~ | ||
**/._* | ||
**/.dockerignore | ||
**/.DS_Store | ||
**/.git/ | ||
**/.gitattributes | ||
**/.gitignore | ||
**/.gitkeep | ||
**/.gitmodules | ||
**/Dockerfile | ||
**/Thumbs.db | ||
.editorconfig | ||
.env* | ||
.php_cs.cache | ||
.travis.yml | ||
app/config/parameters.yml | ||
app/config/*.local.yml | ||
bin/* | ||
!bin/console | ||
!bin/symfony_requirements | ||
composer.phar | ||
docker-compose.override.yaml | ||
docker-compose.override.yml | ||
docker-compose.yaml | ||
docker-compose.yml | ||
docker/mysql/data/ | ||
etc/build/* | ||
node_modules/ | ||
var/* | ||
vendor/ | ||
web/assets/ | ||
web/bundles/ | ||
web/css/ | ||
web/js/ | ||
web/media/ |
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,86 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
# Change these settings to your own preference | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.feature] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.js] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = false | ||
|
||
[*.neon] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.php] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.sh] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.{yaml,yml}] | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = false | ||
|
||
[.gitmodules] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[.php_cs{,.dist}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[composer.json] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[docker-compose{,.override}.{yaml,yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[Dockerfile] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[package.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[phpspec.yml{,.dist}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[phpstan.neon] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[phpunit.xml{,.dist}] | ||
indent_style = space | ||
indent_size = 4 |
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,8 @@ | ||
MYSQL_PASSWORD=!ChangeMe! | ||
MYSQL_ROOT_PASSWORD=!ChangeMe! | ||
PHP_DATE_TIMEZONE=UTC | ||
SYLIUS_MAILER_HOST=mailhog | ||
SYLIUS_MAILER_PASSWORD= | ||
SYLIUS_MAILER_PORT=1025 | ||
SYLIUS_MAILER_USER= | ||
SYLIUS_SECRET=!ChangeMe! |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
ARG PHP_VERSION=7.2 | ||
ARG NODE_VERSION=10 | ||
ARG NGINX_VERSION=1.14 | ||
|
||
FROM php:${PHP_VERSION}-fpm-alpine AS sylius_php | ||
|
||
# persistent / runtime deps | ||
RUN apk add --no-cache \ | ||
acl \ | ||
file \ | ||
gettext \ | ||
git \ | ||
mariadb-client \ | ||
; | ||
|
||
ARG APCU_VERSION=5.1.11 | ||
RUN set -eux; \ | ||
apk add --no-cache --virtual .build-deps \ | ||
$PHPIZE_DEPS \ | ||
freetype-dev \ | ||
icu-dev \ | ||
libjpeg-turbo-dev \ | ||
libpng-dev \ | ||
libtool \ | ||
libwebp-dev \ | ||
libzip-dev \ | ||
mariadb-dev \ | ||
zlib-dev \ | ||
; \ | ||
\ | ||
docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include --with-webp-dir=/usr/include --with-freetype-dir=/usr/include/; \ | ||
docker-php-ext-configure zip --with-libzip; \ | ||
docker-php-ext-install -j$(nproc) \ | ||
exif \ | ||
gd \ | ||
intl \ | ||
pdo_mysql \ | ||
zip \ | ||
; \ | ||
pecl install \ | ||
apcu-${APCU_VERSION} \ | ||
; \ | ||
pecl clear-cache; \ | ||
docker-php-ext-enable \ | ||
apcu \ | ||
opcache \ | ||
; \ | ||
\ | ||
runDeps="$( \ | ||
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ | ||
| tr ',' '\n' \ | ||
| sort -u \ | ||
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ | ||
)"; \ | ||
apk add --no-cache --virtual .sylius-phpexts-rundeps $runDeps; \ | ||
\ | ||
apk del .build-deps | ||
|
||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
COPY docker/php/php.ini /usr/local/etc/php/php.ini | ||
|
||
ARG COMPOSER_AUTH= | ||
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
RUN set -eux; \ | ||
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \ | ||
composer clear-cache | ||
ENV PATH="${PATH}:/root/.composer/vendor/bin" | ||
|
||
WORKDIR /srv/sylius | ||
|
||
# Build for production | ||
ARG SYMFONY_ENV=prod | ||
|
||
# Prevent the reinstallation of vendors at every changes in the source code | ||
COPY composer.json composer.lock ./ | ||
RUN set -eux; \ | ||
composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress --no-suggest; \ | ||
composer clear-cache | ||
|
||
COPY . ./ | ||
|
||
RUN set -eux; \ | ||
mkdir -p var/cache var/logs; \ | ||
composer dump-autoload --classmap-authoritative --no-dev; \ | ||
composer run-script --no-dev post-install-cmd; \ | ||
chmod +x bin/console; sync; \ | ||
bin/console sylius:install:assets; \ | ||
bin/console sylius:theme:assets:install | ||
VOLUME /srv/sylius/var | ||
|
||
VOLUME /srv/sylius/web/media | ||
|
||
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint | ||
RUN chmod +x /usr/local/bin/docker-entrypoint | ||
|
||
ENTRYPOINT ["docker-entrypoint"] | ||
CMD ["php-fpm"] | ||
|
||
FROM node:${NODE_VERSION}-alpine AS sylius_nodejs | ||
|
||
WORKDIR /srv/sylius | ||
|
||
# Build for production | ||
ARG NODE_ENV=production | ||
ARG GULP_ENV=prod | ||
|
||
RUN set -eux; \ | ||
apk add --no-cache --virtual .build-deps \ | ||
g++ \ | ||
gcc \ | ||
make \ | ||
python \ | ||
; | ||
|
||
# Prevent the reinstallation of vendors at every changes in the source code | ||
COPY package.json yarn.lock ./ | ||
RUN set -eux; \ | ||
yarn install; \ | ||
yarn cache clean | ||
|
||
COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private/ | ||
COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private/ | ||
COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private/ | ||
|
||
COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js | ||
COPY --from=sylius_php /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js | ||
|
||
COPY gulpfile.babel.js .babelrc ./ | ||
RUN set -eux; \ | ||
if [ "${NODE_ENV}" = 'production' ]; then \ | ||
NODE_ENV=development yarn install; \ | ||
yarn build; \ | ||
yarn install; \ | ||
yarn cache clean; \ | ||
fi | ||
|
||
COPY docker/nodejs/docker-entrypoint.sh /usr/local/bin/docker-entrypoint | ||
RUN chmod +x /usr/local/bin/docker-entrypoint | ||
|
||
ENTRYPOINT ["docker-entrypoint"] | ||
CMD ["node"] | ||
|
||
FROM nginx:${NGINX_VERSION}-alpine AS sylius_nginx | ||
|
||
COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/ | ||
|
||
WORKDIR /srv/sylius | ||
|
||
COPY --from=sylius_php /srv/sylius/web web/ | ||
COPY --from=sylius_nodejs /srv/sylius/web web/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
"require": { | ||
"php": "^7.1", | ||
|
||
"sylius/sylius": "1.2.*", | ||
"sylius/sylius": "1.3.*@dev", | ||
"symfony/symfony": "^3.4|^4.1" | ||
}, | ||
"require-dev": { | ||
|
@@ -80,12 +80,12 @@ | |
"symfony-var-dir": "var", | ||
"symfony-web-dir": "web", | ||
"symfony-tests-dir": "tests", | ||
"symfony-assets-install": "relative", | ||
"symfony-assets-install": "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. This is necessary as symlinks don't work across containers. |
||
"incenteev-parameters": { | ||
"file": "app/config/parameters.yml" | ||
}, | ||
"branch-alias": { | ||
"dev-master": "1.2-dev" | ||
"dev-master": "1.3-dev" | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's pointless to have database
driver
configurable via environment variable when theserver_version
is fixed here. It's also something that does not change across deployments in an application, so following Symfony Best Practices: