Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
ci: copy theme assets from Docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
opdavies committed Dec 15, 2021
1 parent c898f4d commit 9dd0006
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 21 deletions.
6 changes: 5 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ services:
restart: unless-stopped

node:
image: node:14-alpine
build:
context: .
dockerfile: tools/docker/Dockerfile
target: assets
image: ghcr.io/opdavies/oliverdavies-uk-assets:node-14
working_dir: /node
entrypoint: sh
volumes:
Expand Down
13 changes: 13 additions & 0 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ if [[ ! -t 1 ]]; then
TTY="-T"
fi

function task:build-and-push-images {
export DOCKER_BUILDKIT=1

docker-compose build assets
docker-compose push assets
}

function task:copy-theme-assets {
docker container run --entrypoint sh --name oliverdavies-uk-assets oliverdavies-uk-assets
docker cp oliverdavies-uk-assets:/node/build web/themes/custom/opdavies
docker container rm oliverdavies-uk-assets
}

function task:bash {
task:exec bash "${@}"
}
Expand Down
4 changes: 2 additions & 2 deletions tools/deployment/deploy/after-update-code.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- include: ../includes/build-theme-assets.yml

- name: Install Composer dependencies
composer:
command: install
Expand Down Expand Up @@ -34,5 +36,3 @@
chdir={{ release_web_path }}
register: config_import_result
changed_when: "'There are no changes to import' not in config_import_result.stderr"

- include: ../includes/build-theme-assets.yml
23 changes: 5 additions & 18 deletions tools/deployment/includes/build-theme-assets.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
---
- name: Install theme dependencies
command: >
npm ci
chdir={{ release_theme_path }}
creates={{ release_theme_path }}/node_modules
- name: Generate front-end assets
command: >
npm run production
chdir={{ release_theme_path }}
creates={{ release_theme_path }}/dist
- name: Remove files that are no longer needed
file:
path: "{{ release_theme_path }}/{{ item }}"
state: absent
with_items:
- node_modules
- name: Copy theme dependencies from the Docker container.
command: |
docker-compose pull
./run copy-theme-assets
creates={{ release_theme_path }}/build
20 changes: 20 additions & 0 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,23 @@ COPY composer.json composer.lock /app/
COPY assets /app/assets
COPY tools/patches /app/tools/patches
RUN composer install

###

FROM node:14-alpine AS assets

WORKDIR /node

COPY web/themes/custom/opdavies/package*.json ./

RUN npm install

COPY web/themes/custom/opdavies/postcss.config.js .
COPY web/themes/custom/opdavies/webpack.config.js .
COPY web/themes/custom/opdavies/tailwind.config.js .
COPY web/themes/custom/opdavies/tailwindcss tailwindcss
COPY web/themes/custom/opdavies/assets assets
COPY web/themes/custom/opdavies/templates templates

RUN npm run prod \
&& rm -fr node_modules

0 comments on commit 9dd0006

Please sign in to comment.