diff --git a/README.md b/README.md
index 5fd18d5..37644ce 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ Docker Compose for Node projects with Node, MySQL, MongoDB, NGINX, Certbot and R
- [Non-web project](#Non-Web)
- [Multiple Node containers](#Multi-Node)
- [More options](#More-Options)
+ - [Use Yarn](#Use-Yarn)
- [Change Node entrypoint](#Node-Entrypoint)
- [Change Node environment](#Node-Environment)
- [Change Node version](#Node-Version)
@@ -192,6 +193,17 @@ To customize the NoDock installation, either add a `docker-compose.override.yml`
```bash
docker-compose -f nodock/docker-compose.yml -f docker-compose.dev.yml up -d
```
+
+#### Use Yarn
+Set the `YARN` argument to `true`.
+```yaml
+# docker-compose.override.yml
+[...]
+ node:
+ build:
+ args:
+ - YARN=true
+```
#### Change the node entrypoint
Use `main.js` instead of `index.js`
diff --git a/docker-compose.yml b/docker-compose.yml
index 1804a7c..9a50242 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -9,6 +9,7 @@ services:
- NODE_VERSION=latest
- PROJECT_PATH=/opt/app/
- NODE_ENV=production
+ - YARN=false
volumes:
- ../:/opt/app
extra_hosts:
diff --git a/node/Dockerfile b/node/Dockerfile
index 9a9bc00..89912f5 100644
--- a/node/Dockerfile
+++ b/node/Dockerfile
@@ -7,7 +7,9 @@ RUN apt-get update &&\
ARG NODE_ENV
ARG NODE_VERSION
ARG PROJECT_PATH
+ARG YARN
+ENV YARN=$YARN
ENV PROJECT_PATH=$PROJECT_PATH
ENV NODE_ENV=$NODE_ENV
@@ -18,6 +20,12 @@ RUN groupadd -r www-app &&\
# Install the specified NODE_VERSION or grab latest
RUN n "$NODE_VERSION"
+# Install Yarn
+
+RUN if [ ${YARN} = true ]; then \
+ npm install -g yarn \
+;fi
+
COPY scripts/run-nodock.sh /usr/bin/run-nodock
RUN chmod 700 /usr/bin/run-nodock
diff --git a/node/scripts/run-nodock.sh b/node/scripts/run-nodock.sh
index 1a4ea39..00c2afa 100644
--- a/node/scripts/run-nodock.sh
+++ b/node/scripts/run-nodock.sh
@@ -10,6 +10,10 @@ fi
cd $PROJECT_PATH
-npm install
+if [[ $YARN = true ]]; then
+ yarn install
+else
+ npm install
+fi
su -c "cd $PROJECT_PATH; $SCRIPT" -s /bin/bash www-app
diff --git a/workspace/Dockerfile b/workspace/Dockerfile
index 944e88e..dc8ca61 100644
--- a/workspace/Dockerfile
+++ b/workspace/Dockerfile
@@ -24,6 +24,9 @@ ARG NODE_VERSION
# Install the specified NODE_VERSION or grab latest
RUN n "$NODE_VERSION"
+# Install YARN
+RUN npm i -g yarn
+
##
## Cron
##