Skip to content

Commit 4dc8614

Browse files
committed
kms: Build prod image
1 parent 0011f40 commit 4dc8614

File tree

4 files changed

+46
-89
lines changed

4 files changed

+46
-89
lines changed

kms/dstack-app/builder/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,5 @@ RUN git clone https://github.com/kvinwang/qemu-tdx.git --depth 1 --branch passth
5353
install -m 644 pc-bios/linuxboot_dma.bin /usr/local/share/qemu/ && \
5454
cd .. && rm -rf qemu-tdx
5555
COPY --from=kms-builder /build/dstack/target/x86_64-unknown-linux-musl/release/dstack-kms /usr/local/bin/dstack-kms
56-
COPY entrypoint.sh /entrypoint.sh
5756
COPY .GIT_REV /etc/.GIT_REV
58-
RUN chmod +x /entrypoint.sh
59-
ENTRYPOINT ["/entrypoint.sh"]
6057
CMD ["dstack-kms"]

kms/dstack-app/builder/build-image.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ fi
4646

4747
touch shared/kms-pinned-packages.txt
4848
touch shared/qemu-pinned-packages.txt
49-
GIT_REV=$(git rev-parse HEAD)
49+
GIT_REV=${GIT_REV:-HEAD}
50+
GIT_REV=$(git rev-parse $GIT_REV)
5051
echo $GIT_REV > .GIT_REV
5152

5253
# First build the qemu-builder stage and extract package list

kms/dstack-app/builder/entrypoint.sh

Lines changed: 0 additions & 44 deletions
This file was deleted.

kms/dstack-app/compose-dev.yaml

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,54 +24,57 @@ services:
2424
- 8001:8000
2525

2626
kms:
27-
build:
28-
context: .
29-
dockerfile_inline: |
30-
FROM golang:1.22-alpine@sha256:1699c10032ca2582ec89a24a1312d986a3f094aed3d5c1147b19880afe40e052 AS dstack-mr-builder
31-
WORKDIR /app
32-
RUN apk add --no-cache git
33-
RUN git clone https://github.com/kvinwang/dstack-mr.git
34-
WORKDIR /app/dstack-mr
35-
RUN git checkout 5cf6d917e076f3624eab1b6b662f222ece15600f
36-
RUN CGO_ENABLED=0 go build -ldflags="-extldflags -static" -o /usr/local/bin/dstack-mr
37-
38-
FROM rust:1.86.0@sha256:300ec56abce8cc9448ddea2172747d048ed902a3090e6b57babb2bf19f754081 AS kms-builder
39-
WORKDIR /app
40-
RUN apt-get update && apt-get install -y \
41-
git \
42-
build-essential \
43-
musl-tools \
44-
libssl-dev \
45-
protobuf-compiler \
46-
libprotobuf-dev \
47-
clang \
48-
libclang-dev \
49-
--no-install-recommends \
50-
&& rm -rf /var/lib/apt/lists/*
51-
RUN git clone https://github.com/Dstack-TEE/dstack.git && \
52-
cd dstack && \
53-
git checkout ${GIT_REV}
54-
WORKDIR /app/dstack
55-
RUN rustup target add x86_64-unknown-linux-musl
56-
RUN cargo build --release -p dstack-kms --target x86_64-unknown-linux-musl
57-
58-
FROM alpine:latest
59-
COPY --from=kms-builder /app/dstack/target/x86_64-unknown-linux-musl/release/dstack-kms /usr/local/bin/dstack-kms
60-
COPY --from=kms-builder /app/dstack/kms/dstack-app/entrypoint.sh /entrypoint.sh
61-
COPY --from=dstack-mr-builder /usr/local/bin/dstack-mr /usr/local/bin/dstack-mr
62-
WORKDIR /app/kms
63-
CMD ["/entrypoint.sh"]
27+
image: kvin/kms:latest
6428
volumes:
65-
- kms-volume:/etc/kms
29+
- kms-volume:/kms
6630
- /var/run/dstack.sock:/var/run/dstack.sock
67-
environment:
68-
- IMAGE_DOWNLOAD_URL=${IMAGE_DOWNLOAD_URL}
69-
- ADMIN_TOKEN_HASH=${ADMIN_TOKEN_HASH}
7031
ports:
7132
- 8000:8000
7233
depends_on:
7334
- auth-api
7435
restart: unless-stopped
36+
configs:
37+
- source: kms_config
38+
target: /kms/kms.toml
39+
command: sh -c 'mkdir -p /kms/certs /kms/images && exec dstack-kms -c /kms/kms.toml'
7540

7641
volumes:
7742
kms-volume:
43+
44+
configs:
45+
kms_config:
46+
content: |
47+
[rpc]
48+
address = "0.0.0.0"
49+
port = 8000
50+
51+
[rpc.tls]
52+
key = "/kms/certs/rpc.key"
53+
certs = "/kms/certs/rpc.crt"
54+
55+
[rpc.tls.mutual]
56+
ca_certs = "/kms/certs/tmp-ca.crt"
57+
mandatory = false
58+
59+
[core]
60+
cert_dir = "/kms/certs"
61+
admin_token_hash = "${ADMIN_TOKEN_HASH}"
62+
63+
[core.image]
64+
verify = true
65+
cache_dir = "/kms/images"
66+
download_url = "${IMAGE_DOWNLOAD_URL}"
67+
download_timeout = "2m"
68+
69+
[core.auth_api]
70+
type = "webhook"
71+
72+
[core.auth_api.webhook]
73+
url = "http://auth-api:8000"
74+
75+
[core.onboard]
76+
enabled = true
77+
auto_bootstrap_domain = ""
78+
quote_enabled = true
79+
address = "0.0.0.0"
80+
port = 8000

0 commit comments

Comments
 (0)