build(docker): use Tailwind CLI for generating CSS
This commit is contained in:
parent
84963c8a31
commit
29014d1c56
|
@ -1,3 +1,7 @@
|
||||||
IFTTT_WEBHOOK_URL=
|
IFTTT_WEBHOOK_URL=
|
||||||
|
|
||||||
INTEGROMAT_WEBHOOK_URL=
|
INTEGROMAT_WEBHOOK_URL=
|
||||||
|
|
||||||
|
# Which environment is running? This should be "development" or "production".
|
||||||
|
# NODE_ENV=development
|
||||||
|
NODE_ENV=production
|
||||||
|
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -77,12 +77,6 @@ jobs:
|
||||||
path: node_modules
|
path: node_modules
|
||||||
key: dependencies-npm-${{ hashFiles('package-lock.json') }}
|
key: dependencies-npm-${{ hashFiles('package-lock.json') }}
|
||||||
|
|
||||||
- name: Build the production theme assets
|
|
||||||
run: |
|
|
||||||
cd ${{ matrix.theme-path }}
|
|
||||||
npm clean-install
|
|
||||||
npm run production
|
|
||||||
|
|
||||||
phpunit:
|
phpunit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: "Run ${{ matrix.test-types }} tests"
|
name: "Run ${{ matrix.test-types }} tests"
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@
|
||||||
!/bin/
|
!/bin/
|
||||||
!/config/**
|
!/config/**
|
||||||
!/Dockerfile
|
!/Dockerfile
|
||||||
|
!/docker-compose.override.yaml.example
|
||||||
!/docker-compose.yaml
|
!/docker-compose.yaml
|
||||||
!/phpcs.xml.dist
|
!/phpcs.xml.dist
|
||||||
!/phpstan*.neon
|
!/phpstan*.neon
|
||||||
|
|
30
Dockerfile
30
Dockerfile
|
@ -1,15 +1,29 @@
|
||||||
FROM node:14-alpine AS assets
|
FROM node:14-buster-slim AS assets
|
||||||
|
|
||||||
|
ARG NODE_ENV=production
|
||||||
|
ENV NODE_ENV="${NODE_ENV:-production}" \
|
||||||
|
PATH="${PATH}:/node_modules/.bin"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN mkdir /node_modules \
|
RUN mkdir /node_modules \
|
||||||
chown node:node -R /node_modules /app
|
&& chown node:node -R /node_modules /app
|
||||||
|
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
|
COPY --chown=node:node run .
|
||||||
|
|
||||||
WORKDIR /app/web/themes/custom/opdavies
|
WORKDIR /app/web/themes/custom/opdavies
|
||||||
COPY web/themes/custom/opdavies/.yarnrc .
|
|
||||||
COPY web/themes/custom/opdavies/package.json .
|
COPY --chown=node:node web/themes/custom/opdavies/.yarnrc .
|
||||||
COPY web/themes/custom/opdavies/yarn.lock .
|
COPY --chown=node:node web/themes/custom/opdavies/package.json .
|
||||||
RUN yarn install && yarn cache clear
|
COPY --chown=node:node web/themes/custom/opdavies/yarn.lock .
|
||||||
COPY web/themes/custom/opdavies ./
|
|
||||||
RUN npm run production
|
RUN yarn install && yarn cache clean
|
||||||
|
|
||||||
|
COPY --chown=node:node config ../../../../config
|
||||||
|
|
||||||
|
CMD ["bash"]
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
17
docker-compose.override.yaml.example
Normal file
17
docker-compose.override.yaml.example
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
x-assets: &default-assets
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: assets
|
||||||
|
args:
|
||||||
|
- "NODE_ENV=${NODE_ENV:-production}"
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
tty: true
|
||||||
|
volumes:
|
||||||
|
- '.:/app'
|
||||||
|
|
||||||
|
services:
|
||||||
|
css:
|
||||||
|
<<: *default-assets
|
||||||
|
command: 'yarn build:css'
|
||||||
|
working_dir: /app/web/themes/custom/opdavies
|
|
@ -1,10 +1,3 @@
|
||||||
version: '2.4'
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
assets:
|
|
||||||
mysql_data:
|
|
||||||
node_modules:
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
nginx:
|
nginx:
|
||||||
build:
|
build:
|
||||||
|
@ -12,7 +5,6 @@ services:
|
||||||
target: nginx
|
target: nginx
|
||||||
volumes:
|
volumes:
|
||||||
- assets:/app/web/themes/custom/opdavies/build
|
- assets:/app/web/themes/custom/opdavies/build
|
||||||
- node_modules:/app/web/themes/custom/opdavies/node_modules
|
|
||||||
- ./:/app
|
- ./:/app
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
|
@ -46,3 +38,7 @@ services:
|
||||||
test: ["CMD-SHELL", "bash", "-c", "echo > /dev/tcp/localhost/3306"]
|
test: ["CMD-SHELL", "bash", "-c", "echo > /dev/tcp/localhost/3306"]
|
||||||
interval: 1s
|
interval: 1s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
assets:
|
||||||
|
mysql_data:
|
||||||
|
|
16
run
16
run
|
@ -116,7 +116,21 @@ function task:test:unit {
|
||||||
|
|
||||||
function run-tests {
|
function run-tests {
|
||||||
# Run PHPUnit tests.
|
# Run PHPUnit tests.
|
||||||
docker-compose run php --user ${DOCKER_WEB_USER} php phpunit "${@}"
|
docker-compose run --rm php --user ${DOCKER_WEB_USER} php phpunit "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function task:yarn:build:css {
|
||||||
|
# Build CSS assets, this is meant to be run from within the assets container.
|
||||||
|
local args=()
|
||||||
|
|
||||||
|
if [ "${NODE_ENV}" == "production" ]; then
|
||||||
|
args=(--minify)
|
||||||
|
else
|
||||||
|
args=(--watch)
|
||||||
|
fi
|
||||||
|
|
||||||
|
tailwindcss --postcss --input assets/css/tailwind.pcss \
|
||||||
|
--output build/app.css "${args[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
eval "task:${@:-help}"
|
eval "task:${@:-help}"
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run development",
|
"build:css": "/app/run yarn:build:css"
|
||||||
"development": "encore dev",
|
|
||||||
"prod": "npm run production",
|
|
||||||
"production": "encore production",
|
|
||||||
"watch": "encore dev --watch"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"dependencies": {
|
||||||
"@symfony/webpack-encore": "^1.1.2",
|
|
||||||
"@tailwindcss/aspect-ratio": "^0.2.0",
|
"@tailwindcss/aspect-ratio": "^0.2.0",
|
||||||
"@tailwindcss/forms": "^0.2.1",
|
"@tailwindcss/forms": "^0.2.1",
|
||||||
"@tailwindcss/typography": "^0.4.0",
|
"@tailwindcss/typography": "^0.4.0",
|
||||||
|
@ -20,9 +15,7 @@
|
||||||
"lodash": ">=4.17.19",
|
"lodash": ">=4.17.19",
|
||||||
"postcss": "^8.2.1",
|
"postcss": "^8.2.1",
|
||||||
"postcss-easy-import": "^3.0.0",
|
"postcss-easy-import": "^3.0.0",
|
||||||
"postcss-loader": "^5.2.0",
|
|
||||||
"postcss-nested": "^5.0.5",
|
"postcss-nested": "^5.0.5",
|
||||||
"tailwindcss": "^2.2.19",
|
"tailwindcss": "^2.2.19"
|
||||||
"webpack-notifier": "^1.8.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ module.exports = {
|
||||||
important: true,
|
important: true,
|
||||||
purge: {
|
purge: {
|
||||||
content: [
|
content: [
|
||||||
'config/**/*.yml',
|
'../../../../config/**/*.yml',
|
||||||
'tailwindcss/safelist-classes.txt',
|
'tailwindcss/safelist-classes.txt',
|
||||||
'templates/**/*.html.twig'
|
'templates/**/*.html.twig'
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
let Encore = require('@symfony/webpack-encore')
|
|
||||||
let path = require('path')
|
|
||||||
|
|
||||||
Encore
|
|
||||||
.disableSingleRuntimeChunk()
|
|
||||||
.cleanupOutputBeforeBuild()
|
|
||||||
.setOutputPath('build/')
|
|
||||||
.setPublicPath('/themes/custom/opdavies/build')
|
|
||||||
.setManifestKeyPrefix('build/')
|
|
||||||
|
|
||||||
.addEntry('app', '@/app.js')
|
|
||||||
|
|
||||||
.enablePostCssLoader()
|
|
||||||
|
|
||||||
.addAliases({
|
|
||||||
'@': path.resolve(__dirname, 'assets', 'js'),
|
|
||||||
styles: path.resolve(__dirname, 'assets', 'css')
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!Encore.isProduction()) {
|
|
||||||
Encore.enableSourceMaps()
|
|
||||||
}
|
|
||||||
|
|
||||||
process.env.NODE_ENV =
|
|
||||||
process.env.NODE_ENV || Encore.isProduction() ? 'production' : 'development';
|
|
||||||
|
|
||||||
module.exports = Encore.getWebpackConfig()
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue