Skip to content

Commit

Permalink
bug #835 [docker]Integrate production config docker with Webpack (Fer…
Browse files Browse the repository at this point in the history
…ror)

This PR was merged into the 1.12 branch.

Discussion
----------

FYI #832

The PHP container now needs the frontend files. This is not the most distinguished solution, but it works. I will spend some more time polishing it. But now it is required to fix the 1.12 branch.

PS. it worked on the development image only because the command generated the files and syncs with local filesystem

Commits
-------

9f5f794 [docker]Integrate production config docker with Webpack
  • Loading branch information
jakubtobiasz authored Oct 4, 2022
2 parents 5e6c630 + 9f5f794 commit ea0e221
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ node_modules/
var/*
vendor/
public/assets/
public/build/
public/bundles/
public/css/
public/js/
Expand Down
23 changes: 13 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FROM composer:${COMPOSER_VERSION} AS composer

FROM mlocati/php-extension-installer:${PHP_EXTENSION_INSTALLER_VERSION} AS php_extension_installer

FROM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION} AS sylius_php_prod
FROM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION} AS base

# persistent / runtime deps
RUN apk add --no-cache \
Expand Down Expand Up @@ -92,29 +92,32 @@ RUN set -eux; \
yarn install; \
yarn cache clean

COPY --from=sylius_php_prod /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private/
COPY --from=sylius_php_prod /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private/
COPY --from=sylius_php_prod /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private/
COPY --from=sylius_php_prod /srv/sylius/assets ./assets
COPY --from=base /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Resources/private/
COPY --from=base /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private/
COPY --from=base /srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private/
COPY --from=base /srv/sylius/assets ./assets

COPY webpack.config.js ./
RUN set -eux; \
yarn build:prod;
RUN yarn build:prod

COPY docker/node/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint

ENTRYPOINT ["docker-entrypoint"]
CMD ["yarn", "build"]
CMD ["yarn", "build:prod"]

FROM base AS sylius_php_prod

COPY --from=sylius_node /srv/sylius/public/build public/build

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_prod /srv/sylius/public public/
COPY --from=sylius_node /srv/sylius/public public/
COPY --from=base /srv/sylius/public public/
COPY --from=sylius_node /srv/sylius/public public/

FROM sylius_php_prod AS sylius_php_dev

Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ adminConfig.resolve.alias['sylius/bundle'] = syliusBundles;
adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' });
adminConfig.name = 'admin';

Encore.reset()
Encore.reset();

// App shop config
Encore
Expand Down

0 comments on commit ea0e221

Please sign in to comment.