Skip to content
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

Move SCSS source files out of webroot #1728

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.env.dist
.git/
.gitattributes
.gitignore
.idea/
.mysql/
.project
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ node_modules/
data/cache/phpstan/
public/css/gewis-theme.css
public/css/gewis-theme.css.map
resources/scss/
public/styleguide/
autoload_classmap.php
.mysql
Expand Down
3 changes: 1 addition & 2 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/webResources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ replenish:
@docker cp ./data "$(shell docker compose ps -q web)":/code
@docker compose exec web chown -R www-data:www-data /code/data
@docker compose exec web rm -rf data/cache/module-config-cache.application.config.cache.php
@docker compose exec web php composer.phar dump-autoload --dev
@docker compose exec web composer dump-autoload --dev
@docker compose exec web ./orm orm:generate-proxies

update: updatecomposer updatepackage updatecss updateglide updatedocker
Expand Down Expand Up @@ -146,13 +146,11 @@ checkcomposerunused: loadenv
@XDEBUG_MODE=off vendor/bin/composer-unused

checkcomposeroutdated:
@php composer.phar outdated
@composer outdated

updatecomposer:
@docker cp ./composer.json "$(shell docker compose ps -q web)":/code/composer.json
@docker compose exec web php composer.phar selfupdate
@docker cp "$(shell docker compose ps -q web)":/code/composer.phar ./composer.phar
@docker compose exec web php composer.phar update -W
@docker compose exec web php composer update -W
@docker cp "$(shell docker compose ps -q web)":/code/composer.lock ./composer.lock

updatepackage:
Expand All @@ -167,13 +165,8 @@ updatecss:
@docker cp "$(shell docker compose ps -q web)":/code/public/css/gewis-theme.css ./public/css/gewis-theme.css

updateglide:
@docker compose exec glide php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
@docker compose exec glide php composer-setup.php
@docker compose exec glide php -r "unlink('composer-setup.php');"
@docker cp ./docker/glide/composer.json "$(shell docker compose ps -q glide)":/glide/composer.json
@docker compose exec glide php composer.phar selfupdate
@docker cp "$(shell docker compose ps -q glide)":/glide/composer.phar ./docker/glide/composer.phar
@docker compose exec glide php composer.phar update -W
@docker compose exec glide composer update -W
@docker cp "$(shell docker compose ps -q glide)":/glide/composer.lock ./docker/glide/composer.lock

updatedocker:
Expand Down
14 changes: 0 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"monolog/monolog": "^3.0.0",
"league/glide": "^2.2.0",
"fortawesome/font-awesome": "^6.0.0",
"slowprog/composer-copy-file": "^0.3.0",
"cweagans/composer-patches": "^1.7.1",
"setasign/fpdi": "2.3.6",
"tecnickcom/tcpdf": "6.5.0",
Expand Down Expand Up @@ -135,26 +134,13 @@
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-install-cmd": [
"SlowProg\\CopyFile\\ScriptHandler::copy"
],
"post-update-cmd": [
"SlowProg\\CopyFile\\ScriptHandler::copy"
]
},
"repositories": [
{
"type": "git",
"url": "https://github.com/GEWIS/gewisphp-coding-standards.git"
}
],
"extra": {
"copy-file": {
"vendor/fortawesome/font-awesome/scss/": "public/scss/fontawesome/",
"vendor/fortawesome/font-awesome/webfonts/": "public/fonts/fontawesome/",
"vendor/fortawesome/font-awesome/sprites/": "public/sprites/fontawesome/"
},
"patches": {
"doctrine/orm": {
"Fix issues with SubDecisions.": "https://raw.githubusercontent.com/GEWIS/orm/2.15.x/1-to-1-multiple-join-columns.patch"
Expand Down
54 changes: 1 addition & 53 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed composer.phar
Binary file not shown.
8 changes: 3 additions & 5 deletions docker/glide/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ RUN apk add --no-cache --virtual .build-deps \
FROM php-target as composer-build
WORKDIR /glide

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');"

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY ./composer.json ./composer.lock ./
RUN php composer.phar install -o --no-dev

RUN composer install -o --no-dev

FROM php-target as glide
WORKDIR /glide
Expand Down
Binary file removed docker/glide/composer.phar
Binary file not shown.
45 changes: 29 additions & 16 deletions docker/web/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Compile the language files
# Compile the language files.
FROM alpine:latest AS gewisweb_translations
WORKDIR /code

RUN apk add --no-cache --virtual .runtime-deps \
gettext

COPY ./module/Application/language/*.po .
COPY ./module/Application/language/*.po ./

RUN msgfmt en.po -o en -c --strict -v \
&& msgfmt nl.po -o nl -c --strict -v

# Install dependencies and create final image
FROM php:8.2-fpm-alpine AS gewisweb_web_development
# Install dependencies and create final image.
FROM php:8.2-fpm-alpine AS gewisweb_web_development_base
WORKDIR /code

RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
Expand Down Expand Up @@ -77,24 +78,33 @@ RUN apk add --no-cache --virtual .build-deps \

RUN sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/g' /etc/ImageMagick-7/policy.xml

WORKDIR /code
# Install composer and dependencies.
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY ./composer.json ./composer.lock ./

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');"
RUN composer install

COPY --chown=www-data:www-data ./composer.json ./
RUN php composer.phar install
# Compile the SCSS files.
FROM node:lts-alpine as gewisweb_web_styles
WORKDIR /code

# If you are not a member of the ApplicatieBeheerCommissie comment the line below.
COPY --from=web.docker-registry.gewis.nl/gewisweb_patches:latest . /code
COPY ./package.json ./package-lock.json ./
RUN npm install --omit=dev

COPY --chown=www-data:www-data ./package.json ./package-lock.json ./
RUN npm install --production=false
RUN mkdir public && mkdir public/scss && mkdir public/css

COPY --from=gewisweb_web_development_base /code/vendor ./vendor
COPY ./resources/scss ./resources/scss/

COPY --chown=www-data:www-data ./public/scss ./public/scss/
RUN npm run scss

# Create the final image.
FROM gewisweb_web_development_base AS gewisweb_web_development

# Copy patches for dependencies that cannot be patched through composer. If you are not a member of the
# ApplicatieBeheerCommissie comment the line below.
COPY --from=web.docker-registry.gewis.nl/gewisweb_patches:latest . /code

COPY --chown=www-data:www-data ./docker/web/development/php.ini /usr/local/etc/php/conf.d/default.ini
COPY --chown=www-data:www-data ./docker/web/development/php-fpm.conf /usr/local/etc/php-fpm.d/zz-gewisweb.conf
COPY --chown=www-data:www-data ./config/autoload/local.development.php.dist ./config/autoload/local.php
Expand All @@ -110,9 +120,12 @@ RUN chmod 0775 ./docker-entrypoint.sh

COPY --chown=www-data:www-data . /code
COPY --chown=www-data:www-data --from=gewisweb_translations /code/*.mo /code/module/Application/language/
COPY --chown=www-data:www-data --from=gewisweb_web_styles /code/public/css/gewis-theme.css /code/public/css/gewis-theme.css
RUN cp -R ./vendor/fortawesome/font-awesome/sprites/. ./public/sprites/fontawesome
RUN cp -R ./vendor/fortawesome/font-awesome/webfonts/. ./public/fonts/fontawesome
ENV PHP_IDE_CONFIG="serverName=gewis.nl"

RUN php composer.phar dump-autoload
RUN composer dump-autoload

ARG GIT_COMMIT
ENV GIT_COMMIT=${GIT_COMMIT}
Expand Down
54 changes: 29 additions & 25 deletions docker/web/production/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
# Compile the SCSS files
FROM node:lts-alpine as node-build
WORKDIR /code

COPY ./package.json ./package-lock.json ./
RUN npm install --omit=dev

RUN mkdir public && mkdir public/scss && mkdir public/css

COPY ./public/scss ./public/scss/
RUN npm run scss

# Compile the language files
# Compile the language files.
FROM alpine:latest AS gewisweb_translations
WORKDIR /code

RUN apk add --no-cache --virtual .runtime-deps \
gettext

COPY ./module/Application/language/*.po .
COPY ./module/Application/language/*.po ./

RUN msgfmt en.po -o en -c --strict -v \
&& msgfmt nl.po -o nl -c --strict -v

# Install dependencies
FROM php:8.2-fpm-alpine as php-target
# Create a base image with all PHP dependencies.
FROM php:8.2-fpm-alpine as gewisweb_web_production_base
WORKDIR /code

RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
Expand Down Expand Up @@ -78,17 +67,30 @@ RUN apk add --no-cache --virtual .build-deps \

RUN sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/g' /etc/ImageMagick-7/policy.xml

# Create final image
FROM php-target as gewisweb_web_production
# Install composer and through it the application dependencies.
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY ./composer.json ./composer.lock ./

RUN composer install -o --no-dev

# Compile the SCSS files.
FROM node:lts-alpine as gewisweb_web_styles
WORKDIR /code

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');"
COPY ./package.json ./package-lock.json ./
RUN npm install --omit=dev

COPY ./composer.json ./composer.lock ./
RUN php composer.phar install -o --no-dev
RUN mkdir public && mkdir public/scss && mkdir public/css

COPY --from=gewisweb_web_production_base /code/vendor ./vendor
COPY ./resources/scss ./resources/scss/

RUN npm run scss

# Create the final image.
FROM gewisweb_web_production_base AS gewisweb_web_production

# Copy patches for dependencies that cannot be patched through composer.
COPY --from=web.docker-registry.gewis.nl/gewisweb_patches:latest . /code

COPY --chown=www-data:www-data ./docker/web/production/php.ini /usr/local/etc/php/conf.d/default.ini
Expand All @@ -105,9 +107,11 @@ RUN chmod 0775 ./docker-entrypoint.sh

COPY --chown=www-data:www-data . /code
COPY --chown=www-data:www-data --from=gewisweb_translations /code/*.mo /code/module/Application/language/
COPY --chown=www-data:www-data --from=node-build /code/public/css/gewis-theme.css /code/public/css/gewis-theme.css
COPY --chown=www-data:www-data --from=gewisweb_web_styles /code/public/css/gewis-theme.css /code/public/css/gewis-theme.css
RUN cp -R ./vendor/fortawesome/font-awesome/sprites/. ./public/sprites/fontawesome
RUN cp -R ./vendor/fortawesome/font-awesome/webfonts/. ./public/fonts/fontawesome

RUN php composer.phar dump-autoload -a --no-dev
RUN composer dump-autoload -a --no-dev

ARG GIT_COMMIT
ENV GIT_COMMIT=${GIT_COMMIT}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"scss": "sass --style compressed --no-source-map public/scss/gewis-theme.scss:public/css/gewis-theme.css",
"watch": "sass --watch public/scss/gewis-theme.scss:public/css"
"scss": "sass --style compressed --no-source-map resources/scss/gewis-theme.scss:public/css/gewis-theme.css",
"watch": "sass --watch resources/scss/gewis-theme.scss:public/css"
},
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions public/fonts/fontawesome/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Binary file removed public/fonts/fontawesome/fa-brands-400.eot
Binary file not shown.
Loading
Loading