From 13d76a00fcc641b7be7d1c3605b68f7e0244c2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20G=C4=85sior?= Date: Sun, 27 Sep 2020 20:04:35 +0200 Subject: [PATCH] Container: add Webpack Encore watcher Issue #111 --- container/npm/Dockerfile | 8 ++++++++ container/npm/entrypoint.sh | 8 ++++++++ docker-compose.yaml | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 container/npm/Dockerfile create mode 100755 container/npm/entrypoint.sh diff --git a/container/npm/Dockerfile b/container/npm/Dockerfile new file mode 100644 index 00000000..cca23065 --- /dev/null +++ b/container/npm/Dockerfile @@ -0,0 +1,8 @@ +FROM node:14-alpine3.10 + +RUN apk --no-cache add su-exec entr + +COPY entrypoint.sh /usr/local/bin/custom-entrypoint +ENTRYPOINT ["custom-entrypoint"] + +WORKDIR /srv diff --git a/container/npm/entrypoint.sh b/container/npm/entrypoint.sh new file mode 100755 index 00000000..5cc64a8b --- /dev/null +++ b/container/npm/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh -e + +# Make it easier to run the application first time. :) +if [[ ! -d node_modules ]]; then + su-exec $(stat -c '%u:%g' .) npm install +fi + +echo webpack.config.js | su-exec $(stat -c '%u:%g' .) entr -r npm run watch diff --git a/docker-compose.yaml b/docker-compose.yaml index 077e3a10..0247b8c9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -15,6 +15,11 @@ services: volumes: - '.:/srv:z' + js: + build: 'container/npm' + volumes: + - '.:/srv:z' + db: image: 'mysql:5.7' ports: