Dockerfile

 1# syntax = docker/dockerfile:1.2
 2
 3FROM rust as builder
 4WORKDIR app
 5RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
 6RUN apt-get install -y nodejs
 7COPY . .
 8
 9# Install script dependencies
10RUN --mount=type=cache,target=./script/node_modules \
11    cd ./script && npm install --quiet
12
13# Build CSS
14RUN --mount=type=cache,target=./script/node_modules \
15    script/build-css --release
16
17# Compile server
18RUN --mount=type=cache,target=./script/node_modules \
19    --mount=type=cache,target=/usr/local/cargo/registry \
20    --mount=type=cache,target=./target \
21    cargo build --release --bin zed-server
22
23# Copy server binary out of cached directory
24RUN --mount=type=cache,target=./target \
25    cp /app/target/release/zed-server /app/zed-server
26
27# Copy server binary to the runtime image
28FROM debian:buster-slim as runtime
29RUN apt-get update; \
30    apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates
31WORKDIR app
32COPY --from=builder /app/zed-server /app
33ENTRYPOINT ["/app/zed-server"]