Skip to content

Commit

Permalink
Add buildtool dockerimage of wasi-sdk (envoyproxy#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Sep 16, 2022
1 parent d151a04 commit 9237dd7
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/buildtools-wasi-sdk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build wasi-sdk
on:
push:
branches:
- main
paths:
- buildtools/wasi-sdk/**
- .github/workflows/buildtools-wasi-sdk.yaml
pull_request:
branches:
- main
paths:
- buildtools/wasi-sdk/**
- .github/workflows/buildtools-wasi-sdk.yaml

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2

- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/${{ github.repository }}/buildtools-wasi-sdk

- uses: docker/build-push-action@v3
with:
context: buildtools/wasi-sdk
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
27 changes: 27 additions & 0 deletions buildtools/wasi-sdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2022 The OWASP Coraza contributors
# SPDX-License-Identifier: Apache-2.0

FROM debian:11-slim

RUN apt-get update && apt-get install -y curl gnupg make

RUN curl -sS https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor > /etc/apt/trusted.gpg.d/llvm.gpg && \
echo "deb [signed-by=/etc/apt/trusted.gpg.d/llvm.gpg] http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main" >> /etc/apt/sources.list.d/llvm.list && \
echo "deb-src [signed-by=/etc/apt/trusted.gpg.d/llvm.gpg] http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main" >> /etc/apt/sources.list.d/llvm.list

RUN apt-get update && apt-get install -y clang-14 lld-14

ADD https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sysroot-16.0.tar.gz /
RUN tar -xf wasi-sysroot-16.0.tar.gz

ADD https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/libclang_rt.builtins-wasm32-wasi-16.0.tar.gz /
RUN tar -xf libclang_rt.builtins-wasm32-wasi-16.0.tar.gz -C /usr/lib/llvm-14/lib/clang/14.0.6/

ENV CC clang-14
ENV CXX clang++-14
ENV LD wasm-ld-14
ENV AR llvm-ar-14
ENV RANLIB llvm-ranlib-14
ENV CFLAGS -O3 --target=wasm32-wasi --sysroot=/wasi-sysroot
ENV CXXFLAGS -O3 -fno-exceptions --target=wasm32-wasi --sysroot=/wasi-sysroot
ENV LDFLAGS ${CXXFLAGS} --rtlib=compiler-rt -Wl,--demangle,--allow-undefined

0 comments on commit 9237dd7

Please sign in to comment.