DEV: Clean yarn cache after yarn install (#568)

DEV: Clean yarn cache after yarn install (#568)

The cache is not required to run the application. This should make the docker image much smaller.

We may want to re-evaluate this decision when switching to yarn v2, which has a very different caching system.

diff --git a/image/base/Dockerfile b/image/base/Dockerfile
index 09024e5..bca5e3c 100644
--- a/image/base/Dockerfile
+++ b/image/base/Dockerfile
@@ -141,5 +141,6 @@ RUN useradd discourse -s /bin/bash -m -U &&\
     cd /var/www/discourse &&\
     sudo -u discourse bundle install --deployment --jobs 4 --without test development &&\
     sudo -u discourse yarn install --production &&\
+    sudo -u discourse yarn cache clean &&\
     bundle exec rake maxminddb:get &&\
     find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
diff --git a/templates/web.template.yml b/templates/web.template.yml
index 53cc64d..ae50bf8 100644
--- a/templates/web.template.yml
+++ b/templates/web.template.yml
@@ -156,7 +156,7 @@ run:
   - exec:
       cd: $home
       cmd:
-        - "[ ! -d 'node_modules' ] || su discourse -c 'yarn install --production'"
+        - "[ ! -d 'node_modules' ] || su discourse -c 'yarn install --production && yarn cache clean'"
 
   - exec:
       cd: $home

GitHub sha: b259c8d38e0f42288fd279c9f9efd3cefbc2c1cb

This commit appears in #568 which was approved by OsamaSayegh. It was merged by davidtaylorhq.