This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
21 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,17 +30,6 @@ jobs: | |
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.IMAGE_NAME }} | ||
- name: Set up Bazel cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: bazel-cache | ||
key: bazel-${{ matrix.platform }}-${{ hashFiles('Dockerfile') }} | ||
restore-keys: bazel-${{ matrix.platform }} | ||
- name: Inject Bazel cache into Docker | ||
uses: reproducible-containers/[email protected] | ||
with: | ||
cache-source: bazel-cache | ||
cache-target: /root/.cache/bazel | ||
- name: Build and push | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,11 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
FROM debian:bookworm AS builder | ||
ARG TARGETARCH | ||
ARG LLVM_VERSION=17 | ||
|
||
RUN <<EOT | ||
rm -f /etc/apt/apt.conf.d/docker-clean | ||
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
EOT | ||
|
||
# Install LLVM | ||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
--mount=type=cache,target=/var/lib/apt,sharing=locked <<EOT | ||
apt-get update | ||
apt-get install -y --no-install-recommends curl gnupg git patch ca-certificates python3 python3-distutils tcl | ||
echo " | ||
deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-${LLVM_VERSION} main | ||
deb-src http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-${LLVM_VERSION} main | ||
" > /etc/apt/sources.list.d/llvm.list | ||
curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - | ||
apt-get update | ||
apt-get install -y --no-install-recommends \ | ||
llvm-${LLVM_VERSION} \ | ||
lld-${LLVM_VERSION} \ | ||
clang-${LLVM_VERSION} \ | ||
libc++-${LLVM_VERSION}-dev \ | ||
libc++abi-${LLVM_VERSION}-dev \ | ||
libunwind-${LLVM_VERSION}-dev | ||
EOT | ||
|
||
# Install bazelisk | ||
RUN <<EOT | ||
curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-${TARGETARCH} -o /usr/local/bin/bazelisk | ||
chmod +x /usr/local/bin/bazelisk | ||
EOT | ||
|
||
# Download workerd source code | ||
RUN apt-get update && apt-get install -y curl | ||
WORKDIR /workspace | ||
RUN curl -L https://github.com/cloudflare/workerd/archive/refs/tags/v1.20240605.0.tar.gz | tar -zx --strip-component=1 -C ./ | ||
|
||
# Patch workerd | ||
COPY workerd.patch ./ | ||
RUN patch -p1 < workerd.patch | ||
|
||
# Build workerd | ||
RUN <<EOT | ||
echo " | ||
build:linux --action_env=CC=/usr/lib/llvm-${LLVM_VERSION}/bin/clang --action_env=CXX=/usr/lib/llvm-${LLVM_VERSION}/bin/clang++ | ||
build:linux --host_action_env=CC=/usr/lib/llvm-${LLVM_VERSION}/bin/clang --host_action_env=CXX=/usr/lib/llvm-${LLVM_VERSION}/bin/clang++ | ||
" >> .bazelrc | ||
EOT | ||
|
||
RUN --mount=type=cache,target=/root/.cache/bazelisk \ | ||
--mount=type=cache,target=/root/.cache/bazel <<EOT | ||
bazelisk build --config=thin-lto -c opt //src/workerd/server:workerd | ||
strip -S bazel-bin/src/workerd/server/workerd | ||
cp bazel-bin/src/workerd/server/workerd /usr/local/bin/workerd | ||
EOT | ||
COPY download-workerd.sh ./ | ||
RUN ARCH=${TARGETARCH} ./download-workerd.sh | ||
|
||
FROM gcr.io/distroless/cc-debian12:nonroot | ||
COPY --from=builder /usr/local/bin/workerd /usr/local/bin/workerd | ||
COPY --from=builder /workspace/bin/workerd /usr/local/bin/workerd | ||
ENTRYPOINT ["workerd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail | ||
|
||
pkg_version=1.20240605.0 | ||
target_path=./bin/workerd | ||
|
||
if [[ $ARCH == arm* ]]; then | ||
pkg_arch=arm64 | ||
else | ||
pkg_arch=64 | ||
fi | ||
|
||
set -x | ||
mkdir -p "$(dirname $target_path)" | ||
curl -L "https://github.com/cloudflare/workerd/releases/download/v${pkg_version}/workerd-linux-${pkg_arch}.gz" | gzip -d > "$target_path" | ||
chmod +x "$target_path" |
This file was deleted.
Oops, something went wrong.