Skip to content

Commit a98f034

Browse files
committed
feat: first version
Signed-off-by: Michael Dawson <[email protected]>
1 parent d9016fb commit a98f034

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
name: Build and publish the wasm builder container
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
push:
7+
branches: ['main']
8+
paths:
9+
- container-build-info/**
10+
workflow_dispatch:
11+
12+
# We push to the github registry with the image name that matches the repository
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
# Run on the latest available version of Ubuntu.
18+
jobs:
19+
build-and-push-image:
20+
runs-on: ubuntu-latest
21+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
22+
permissions:
23+
contents: read
24+
packages: write
25+
attestations: write
26+
id-token: write
27+
#
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Get Git commit timestamps
33+
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
34+
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Extract metadata (tags, labels) for Docker
42+
id: meta
43+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
47+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
48+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
49+
- name: Build and push Docker image
50+
id: push
51+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
52+
with:
53+
context: "{{defaultContext}}:container-build-info"
54+
push: true
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
env:
58+
SOURCE_DATE_EPOCH: 0
59+
60+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
61+
- name: Generate artifact attestation
62+
uses: actions/attest-build-provenance@v1
63+
with:
64+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
65+
subject-digest: ${{ steps.push.outputs.digest }}
66+
push-to-registry: true
67+
68+

container-build-info/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Modify these to update to newer versions
2+
FROM node:22-alpine3.19@sha256:3cb4748ed93c45cf4622c3382a5ce063af1fcbc5f3da6d2b669352ebace9f76d
3+
ARG BINARYEN_VERSION=116
4+
5+
ARG UID=1000
6+
ARG GID=1000
7+
8+
# set SOURCE_DATE_EPOCH for reproduciability - https://reproducible-builds.org/docs/source-date-epoch/
9+
ENV SOURCE_DATE_EPOCH: 0
10+
11+
ENV ROOT_DIR /home/node
12+
ENV METADATA_DIR $ROOT_DIR/metadata
13+
RUN mkdir $METADATA_DIR
14+
ENV WORKDIR_DIR $ROOT_DIR/build
15+
RUN mkdir WORKDIR_DIR
16+
WORKDIR $WORKDIR_DIR
17+
18+
# Keep a copy of the Dockerfile used
19+
COPY Dockerfile /home/node/metadata/Dockerfile
20+
21+
# Install required system packages
22+
RUN apk add -U clang lld wasi-sdk
23+
RUN apk info -v >/home/node/metadata/apk-info
24+
25+
# Install BINARYEN
26+
RUN wget https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYEN_VERSION/binaryen-version_$BINARYEN_VERSION-x86_64-linux.tar.gz && \
27+
tar -zxvf binaryen-version_$BINARYEN_VERSION-x86_64-linux.tar.gz binaryen-version_$BINARYEN_VERSION/bin/wasm-opt && \
28+
mv binaryen-version_$BINARYEN_VERSION/bin/wasm-opt ./ && \
29+
rm binaryen-version_$BINARYEN_VERSION-x86_64-linux.tar.gz && \
30+
rm -rf binaryen-version_$BINARYEN_VERSION && \
31+
chmod +x ./wasm-opt
32+
ENV WASM_OPT=$WORKDIR_DIR/wasm-opt
33+
RUN echo "Binaryen-version: $BINARYEN_VERSION" >$METADATA_DIR/binaryen-info
34+
RUN echo "Binaryen-url: https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYEN_VERSION/binaryen-version_$BINARYEN_VERSION-x86_64-linux.tar.gz" >>$METADATA_DIR/binaryen-info
35+
RUN echo "Binaryen-binary: $WASM_OPT" >>$METADATA_DIR/binaryen-info
36+
37+
USER node

0 commit comments

Comments
 (0)