Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
171 lines (140 loc) 路 5.85 KB
/
Copy pathDockerfile
File metadata and controls
171 lines (140 loc) 路 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# syntax=docker/dockerfile:1
# Published flavors are built from the named final stages: bookworm, slim,
# and alpine. The unqualified image uses the final `default` stage, which
# intentionally aliases slim.
ARG RUST_VERSION=1.99.0
ARG DEBIAN_SUITE=bookworm
ARG ALPINE_VERSION=3.23
ARG VERSION=source
ARG REVISION=unknown
# Container images are headless: no terminal client or voice session. A full
# build (empty value) also needs the Linux audio development packages listed
# in docs/user/native-voice.md, which these builder stages do not install.
ARG CARGO_ARGS="--no-default-features"
FROM rust:${RUST_VERSION}-slim-${DEBIAN_SUITE} AS builder-gnu
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
ARG TARGETARCH
ARG CARGO_ARGS
COPY Cargo.toml Cargo.lock build.rs install.sh ./
COPY src ./src
COPY docs/user ./docs/user
RUN --mount=type=cache,id=kit-cargo-registry,sharing=locked,target=/usr/local/cargo/registry \
--mount=type=cache,id=kit-gnu-target-${TARGETARCH},sharing=locked,target=/src/target \
cargo build --locked --release --bin kit $CARGO_ARGS \
&& strip --strip-unneeded target/release/kit \
&& cp target/release/kit /kit
# Alpine is a separate musl build. Do not copy the glibc artifact above into
# this stage or add a libc compatibility shim to the runtime image.
FROM rust:${RUST_VERSION}-alpine${ALPINE_VERSION} AS builder-musl
# Dynamic musl matches the runtime image's shared libstdc++. Keep this scoped
# to Alpine: this is not a fully static musl distribution.
ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk add --no-cache \
build-base \
cmake \
linux-headers \
perl \
pkgconf
WORKDIR /src
ARG TARGETARCH
ARG CARGO_ARGS
COPY Cargo.toml Cargo.lock build.rs install.sh ./
COPY src ./src
COPY docs/user ./docs/user
RUN --mount=type=cache,id=kit-cargo-registry,sharing=locked,target=/usr/local/cargo/registry \
--mount=type=cache,id=kit-musl-target-${TARGETARCH},sharing=locked,target=/src/target \
cargo build --locked --release --bin kit $CARGO_ARGS \
&& strip --strip-unneeded target/release/kit \
&& cp target/release/kit /kit
FROM debian:${DEBIAN_SUITE} AS bookworm
ARG VERSION
ARG REVISION
LABEL org.opencontainers.image.title="Kit" \
org.opencontainers.image.description="Headless coding agent runtime" \
org.opencontainers.image.source="https://github.com/speakeasy-api/kit" \
org.opencontainers.image.url="https://github.com/speakeasy-api/kit" \
org.opencontainers.image.documentation="https://github.com/speakeasy-api/kit#readme" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}"
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates git libstdc++6 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 1000 kit \
&& useradd --uid 1000 --gid 1000 --create-home --no-log-init --shell /bin/sh kit \
&& mkdir -p /workspace \
&& chown kit:kit /workspace
COPY --from=builder-gnu /kit /usr/local/bin/kit
RUN /usr/local/bin/kit --version
COPY LICENSE THIRD_PARTY_NOTICES.md /usr/share/doc/kit/
COPY third_party/licenses /usr/share/doc/kit/third_party/licenses
ENV HOME=/home/kit
WORKDIR /workspace
USER kit
EXPOSE 8081
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/kit"]
CMD ["--help"]
FROM debian:${DEBIAN_SUITE}-slim AS slim
ARG VERSION
ARG REVISION
LABEL org.opencontainers.image.title="Kit" \
org.opencontainers.image.description="Headless coding agent runtime" \
org.opencontainers.image.source="https://github.com/speakeasy-api/kit" \
org.opencontainers.image.url="https://github.com/speakeasy-api/kit" \
org.opencontainers.image.documentation="https://github.com/speakeasy-api/kit#readme" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}"
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates git libstdc++6 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 1000 kit \
&& useradd --uid 1000 --gid 1000 --create-home --no-log-init --shell /bin/sh kit \
&& mkdir -p /workspace \
&& chown kit:kit /workspace
COPY --from=builder-gnu /kit /usr/local/bin/kit
RUN /usr/local/bin/kit --version
COPY LICENSE THIRD_PARTY_NOTICES.md /usr/share/doc/kit/
COPY third_party/licenses /usr/share/doc/kit/third_party/licenses
ENV HOME=/home/kit
WORKDIR /workspace
USER kit
# Remote ACP examples conventionally bind this port. Kit does not open a
# listener unless the selected command asks it to.
EXPOSE 8081
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/kit"]
CMD ["--help"]
FROM alpine:${ALPINE_VERSION} AS alpine
ARG VERSION
ARG REVISION
LABEL org.opencontainers.image.title="Kit" \
org.opencontainers.image.description="Headless coding agent runtime" \
org.opencontainers.image.source="https://github.com/speakeasy-api/kit" \
org.opencontainers.image.url="https://github.com/speakeasy-api/kit" \
org.opencontainers.image.documentation="https://github.com/speakeasy-api/kit#readme" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}"
RUN apk add --no-cache ca-certificates git libstdc++ \
&& addgroup -S -g 1000 kit \
&& adduser -S -D -u 1000 -G kit -h /home/kit -s /bin/sh kit \
&& mkdir -p /workspace \
&& chown kit:kit /workspace
COPY --from=builder-musl /kit /usr/local/bin/kit
RUN /usr/local/bin/kit --version
COPY LICENSE THIRD_PARTY_NOTICES.md /usr/share/doc/kit/
COPY third_party/licenses /usr/share/doc/kit/third_party/licenses
ENV HOME=/home/kit
WORKDIR /workspace
USER kit
EXPOSE 8081
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/kit"]
CMD ["--help"]
# Keep the unqualified image on the conservative glibc/slim flavor.
FROM slim AS default