@@ -91,6 +91,8 @@ RUN pip3 install \
9191
9292RUN apk add --no-cache go nodejs npm openssh-client patch
9393
94+ WORKDIR /usr/src/josh
95+
9496FROM dev as dev-local
9597
9698RUN mkdir -p /opt/cache && \
@@ -121,21 +123,26 @@ RUN adduser \
121123 -g '' \
122124 dev
123125
124- FROM dev as dev-ci
126+ FROM dev as dev-cache
125127
126128COPY --from=dev-planner /usr/src/josh/recipe.json .
127129ENV CARGO_TARGET_DIR=/opt/cargo-target
130+
131+ FROM dev-cache as dev-ci
132+
128133RUN cargo chef cook --workspace --recipe-path recipe.json
129134
130135RUN mkdir -p josh-ui
131136COPY josh-ui/package.json josh-ui/package-lock.json josh-ui/
132137RUN cd josh-ui && npm install
133138
134- FROM dev as build
139+ FROM dev-cache as build
135140
136- WORKDIR /usr/src/josh
137- COPY . .
141+ RUN cargo chef cook --release --workspace --recipe-path recipe.json
142+
143+ COPY Cargo.toml Cargo.lock josh-ui josh-ui/
138144RUN cargo build -p josh-ui --release
145+ COPY . .
139146RUN --mount=target=.git,from=git \
140147 cargo build -p josh-proxy -p josh-ssh-shell --release
141148
@@ -159,8 +166,8 @@ RUN apk add --no-cache \
159166COPY --from=dev --link=false /opt/git-install /opt/git-install
160167ENV PATH=${PATH}:/opt/git-install/bin
161168
162- COPY --from=build --link=false /usr/src/josh/ target/release/josh-proxy /usr/bin/
163- COPY --from=build --link=false /usr/src/josh/ target/release/josh-ssh-shell /usr/bin/
169+ COPY --from=build --link=false /opt/cargo- target/release/josh-proxy /usr/bin/
170+ COPY --from=build --link=false /opt/cargo- target/release/josh-ssh-shell /usr/bin/
164171COPY --from=build --link=false /usr/src/josh/static/ /josh/static/
165172
166173ARG S6_OVERLAY_VERSION=3.1.2.1
0 commit comments