Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (53 loc) · 2.54 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (53 loc) · 2.54 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
# syntax=docker/dockerfile:1
#
# Two images, two roles:
# client the container-side helper and CLI, for an embedding image to COPY from
# host the broker, with gh, for running `gcb daemon`
#
# Local build:
# docker build --target client -t code-vaults/gcb-client:dev .
# docker build --target host -t code-vaults/gcb-host:dev .
FROM node:24-slim AS build
WORKDIR /src
RUN corepack enable
COPY package.json yarn.lock .yarnrc.yml tsconfig.json tsconfig.build.base.json tsconfig.build.json ./
COPY packages ./packages
COPY scripts ./scripts
RUN corepack yarn install --immutable \
&& corepack yarn build \
&& mkdir -p /packs \
&& npm pack ./packages/core ./packages/client ./packages/host --pack-destination /packs
FROM node:24-slim AS client
COPY --from=build /packs /packs
RUN npm install -g --omit=dev /packs/gcb-core-*.tgz /packs/gcb-client-*.tgz \
&& rm -rf /packs /root/.npm /tmp/* \
&& find /usr/local/lib/node_modules/gcb-*/lib -type f -name '*.map' -delete \
&& npm cache clean --force
ENTRYPOINT ["gcb"]
# The broker runs gh itself, against the App's token; this must not rely on a host gh install.
FROM node:24-slim AS host-base
ARG APT_MIRROR=mirrors.aliyun.com
RUN --mount=type=cache,id=apt_cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=apt_lists,target=/var/lib/apt/lists,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
&& for f in /etc/apt/sources.list /etc/apt/sources.list.d/debian.sources; do \
if [ -f "$f" ]; then sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" "$f"; fi; \
done \
&& apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl \
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
-o /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
> /etc/apt/sources.list.d/github-cli.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends gh \
&& gh --version
FROM host-base AS host
COPY --from=build /packs /packs
RUN npm install -g --omit=dev /packs/gcb-core-*.tgz /packs/gcb-host-*.tgz \
&& rm -rf /packs /root/.npm /tmp/* \
&& find /usr/local/lib/node_modules/gcb-*/lib -type f -name '*.map' -delete \
&& npm cache clean --force
CMD ["gcb", "daemon"]