From 7cd3dce007b91734d49135c663db7ba8ff028902 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Mon, 23 Dec 2024 16:52:19 +0800 Subject: [PATCH] Remove `git reset --hard` command in web template to reduce layer size (#903) I noticed that use running `git reset --hard` results in ~133MB being added to the final layer generated by `launcher bootstrap`. However, I can not figure out why we would need to run `git reset --hard` at all. Even if there is a reason to run `git reset --hard`, it should not be the default. If someone for whatever reason needs to run `git reset --hard`, they should do so using the `before_code` hook. To replicate the problem, one can run the following steps: 1. In the `discourse_docker` repository, create a file named `containers/test.yml` with the following contents: ``` base_image: discourse/base:2.0.20241223-0016 run: - exec: sudo -H -E -u discourse bash -c "cd /var/www/discourse && git reset --hard" ``` 2. Run `./launcher bootstrap test` 3. Run `docker history local_discourse/test` and see that the new layer created by `./launcher bootstrap` is roughly 133MB. ``` IMAGE CREATED CREATED BY SIZE COMMENT 012471f3c5e4 2 minutes ago /bin/bash -c /usr/local/bin/pups --stdin 133MB ``` --- templates/web.template.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/web.template.yml b/templates/web.template.yml index cd33391..9b541c9 100644 --- a/templates/web.template.yml +++ b/templates/web.template.yml @@ -91,7 +91,6 @@ run: cd: $home hook: code cmd: - - sudo -H -E -u discourse git reset --hard - sudo -H -E -u discourse git clean -f # TODO Remove the special handling of shallow clones when everyone uses images without that clone type - |- -- 2.25.1