Skip to content

Commit b7fbfcc

Browse files
committed
* Dockerized the buildchain, using craft-plugin-manifest for the webpack HMR bridge
Signed-off-by: Andrew Welch <andrew@nystudio107.com>
1 parent e98a3eb commit b7fbfcc

File tree

10 files changed

+57
-564
lines changed

10 files changed

+57
-564
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 1.2.15 - UNRELEASED
44
### Changed
5-
* Updated build system infra
5+
* Dockerized the buildchain, using `craft-plugin-manifest` for the webpack HMR bridge
66

77
## 1.2.14 - 2021.01.03
88
### Changed

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG TAG=12-alpine
2+
FROM nystudio107/node-dev-base:$TAG
3+
4+
WORKDIR /app/buildchain/
5+
6+
CMD ["run build"]
7+
8+
ENTRYPOINT ["npm"]

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
TAG?=12-alpine
2+
3+
docker:
4+
docker build \
5+
. \
6+
-t nystudio107/transcoder-buildchain:${TAG} \
7+
--build-arg TAG=${TAG} \
8+
--no-cache
9+
npm:
10+
docker container run \
11+
--name transcoder-buildchain \
12+
--network plugindev_default \
13+
--rm \
14+
-t \
15+
-p 8080:8080 \
16+
-v `pwd`:/app \
17+
nystudio107/transcoder-buildchain:${TAG} \
18+
$(filter-out $@,$(MAKECMDGOALS))
19+
%:
20+
@:
21+
# ref: https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line

buildchain/.env.example

Lines changed: 0 additions & 6 deletions
This file was deleted.

buildchain/example.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# webpack example settings for Docker
2+
PUBLIC_PATH=""
3+
DEVSERVER_PUBLIC="http://localhost:8080"
4+
DEVSERVER_HOST="0.0.0.0"
5+
DEVSERVER_POLL=0
6+
DEVSERVER_PORT=8080

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
],
3030
"require": {
3131
"craftcms/cms": "^3.1.0",
32+
"nystudio107/craft-plugin-manifest": "^1.0.0",
3233
"mikehaertl/php-shellcommand": "~1.2"
3334
},
3435
"autoload": {

src/Transcoder.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010

1111
namespace nystudio107\transcoder;
1212

13+
use nystudio107\transcoder\assetbundles\transcoder\TranscoderAsset;
1314
use nystudio107\transcoder\services\Transcode;
1415
use nystudio107\transcoder\variables\TranscoderVariable;
1516
use nystudio107\transcoder\models\Settings;
1617

18+
use nystudio107\pluginmanifest\services\ManifestService;
19+
1720
use Craft;
1821
use craft\base\Plugin;
1922
use craft\console\Application as ConsoleApplication;
@@ -41,8 +44,9 @@
4144
* @package Transcode
4245
* @since 1.0.0
4346
*
44-
* @property Transcode $transcode
45-
* @property Settings $settings
47+
* @property Transcode $transcode
48+
* @property Settings $settings
49+
* @property ManifestService $manifest
4650
* @method Settings getSettings()
4751
*/
4852
class Transcoder extends Plugin
@@ -133,14 +137,25 @@ protected function createSettingsModel()
133137
*/
134138
protected function addComponents()
135139
{
140+
// Register the manifest service
141+
$this->set('manifest', [
142+
'class' => ManifestService::class,
143+
'assetClass' => TranscoderAsset::class,
144+
'devServerManifestPath' => 'http://transcoder-buildchain:8080/',
145+
'devServerPublicPath' => 'http://transcoder-buildchain:8080/',
146+
]);
147+
136148
// Register our variables
137149
Event::on(
138150
CraftVariable::class,
139151
CraftVariable::EVENT_INIT,
140152
function (Event $event) {
141153
/** @var CraftVariable $variable */
142154
$variable = $event->sender;
143-
$variable->set('transcoder', TranscoderVariable::class);
155+
$variable->set('transcoder', [
156+
'class' => TranscoderVariable::class,
157+
'manifestService' => $this->manifest,
158+
]);
144159
}
145160
);
146161
}

0 commit comments

Comments
 (0)