Skip to content

Commit 98c5337

Browse files
Warmup yarn and bundle caches in dev image (#832)
Uses a multi-stage build with bind mount to avoid adding the discourse repo itself to the layers
1 parent 7b0e4b4 commit 98c5337

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

image/discourse_dev/Dockerfile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# NAME: discourse/discourse_dev
22
# VERSION: release
3-
FROM discourse/base:slim
3+
4+
ARG from_tag=slim
5+
6+
FROM discourse/base:$from_tag AS repo-fetcher
7+
WORKDIR /repo
8+
RUN chown discourse .
9+
USER discourse
10+
RUN git clone https://github.com/discourse/discourse . --depth 1
11+
12+
FROM discourse/base:$from_tag
413

514
#LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\""
615

@@ -49,3 +58,18 @@ RUN wget -qO /tmp/mailhog https://github.com/mailhog/MailHog/releases/download/v
4958
&& mv /tmp/mailhog /usr/local/bin/mailhog\
5059
&& chmod +x /usr/local/bin/mailhog\
5160
&& rm -rf /tmp/*
61+
62+
USER discourse
63+
64+
# Warm global bundle cache, then delete the compressed `cache/` versions (`/gem/` are enough)
65+
RUN --mount=type=bind,src=/repo,from=repo-fetcher,target=/tmp/discourse-clone,readwrite \
66+
cd /tmp/discourse-clone \
67+
&& bundle install --deployment \
68+
&& rm -rf /home/discourse/.bundle/gems/ruby/*/cache/*
69+
70+
# Warm global yarn cache
71+
RUN --mount=type=bind,src=/repo,from=repo-fetcher,target=/tmp/discourse-clone,readwrite \
72+
cd /tmp/discourse-clone \
73+
&& yarn install
74+
75+
USER root

0 commit comments

Comments
 (0)