forked from serverless-dns/serverless-dns
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* gh-action: ossf/scorecard-action#997 * dockerfile: node 22 * gh-action: wrangler 3.56 * wrangler: upload source maps * fly: mmap to read trie on disk * node: rmv webpack for backend * use mmap for node 22 * node: type assertions with type accessors * node: use @aryaskov/mmap-io * deno: v1.44.4 * node: fix container cwd * gh-action: denoland/deployctl version * deno: import_map mmap-io * fly: webpack bundle target node 22 * fly: webpack externalize native module mmap * node: rmv unused var from blocklists.js * node: omit dev deps in docker * fly: bundle node_modules instead of copying brings down image size down from 900+mb (400mb+ due to node_modules, mostly devDependencies) to 300mb+ * fly: do not omit-dev in setup (dep: webpack) * fly: fix entrypoint * gh-action: ghcr for node-alpine mk1 --------- Co-authored-by: ignoramous <[email protected]> Co-authored-by: Murtaza Aliakbar <[email protected]>
- Loading branch information
1 parent
8763a91
commit d139778
Showing
12 changed files
with
128 additions
and
19 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
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
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,60 @@ | ||
name: 🔄 runc | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: "ghcr.io" | ||
IMAGE_NAME: ${{ github.repository }} | ||
GIT_REF: ${{ github.event.inputs.git-ref || github.ref }} | ||
|
||
# docs.github.com/en/actions/publishing-packages/publishing-docker-images | ||
jobs: | ||
nodejs: | ||
name: 🚀 Node on Alpine | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
|
||
steps: | ||
- name: 🚚 Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.GIT_REF }} | ||
fetch-depth: 0 | ||
|
||
- name: 🔐 Login | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: 🏷️ Metadata | ||
id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: 🛠 Build | ||
id: push | ||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: . | ||
file: ./node.Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: 📕 Attest | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | ||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: true |
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 |
---|---|---|
|
@@ -37,12 +37,20 @@ jobs: | |
egress-policy: audit | ||
|
||
- name: "Checkout code" | ||
<<<<<<< HEAD | ||
uses: actions/checkout@v4 | ||
======= | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
>>>>>>> serverless-dns-main | ||
with: | ||
persist-credentials: false | ||
|
||
- name: "Run analysis" | ||
<<<<<<< HEAD | ||
uses: ossf/[email protected] | ||
======= | ||
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 | ||
>>>>>>> serverless-dns-main | ||
with: | ||
results_file: results.sarif | ||
results_format: sarif | ||
|
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"process": "https://deno.land/[email protected]/node/process.ts", | ||
"@serverless-dns/dns-parser": "https://github.com/serverless-dns/dns-parser/raw/v2.1.2/index.js", | ||
"@serverless-dns/lfu-cache": "https://github.com/serverless-dns/lfu-cache/raw/v3.4.1/lfu.js", | ||
"@serverless-dns/trie/": "https://github.com/serverless-dns/trie/raw/v0.0.13/src/" | ||
"@serverless-dns/trie/": "https://github.com/serverless-dns/trie/raw/v0.0.13/src/", | ||
"@riaskov/mmap-io": "https://github.com/ARyaskov/mmap-io/raw/v1.4.3/src" | ||
} | ||
} |
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,27 +1,34 @@ | ||
FROM node:20 as setup | ||
FROM node:22 as setup | ||
# git is required if any of the npm packages are git[hub] packages | ||
RUN apt-get update && apt-get install git -yq --no-install-suggests --no-install-recommends | ||
WORKDIR /node-dir | ||
WORKDIR /app | ||
COPY . . | ||
# get deps, build, bundle | ||
RUN npm i | ||
# webpack externalizes native modules (@riaskov/mmap-io) | ||
RUN npm run build:fly | ||
# or RUN npx webpack --config webpack.fly.cjs | ||
# download blocklists and bake them in the img | ||
RUN export BLOCKLIST_DOWNLOAD_ONLY=true && node ./dist/fly.mjs | ||
# or RUN export BLOCKLIST_DOWNLOAD_ONLY=true && node ./src/server-node.js | ||
|
||
# stage 2 | ||
FROM node:alpine AS runner | ||
# pin to node22 for native deps (@ariaskov/mmap-io) | ||
FROM node:22-alpine AS runner | ||
|
||
# env vals persist even at run-time: archive.is/QpXp2 | ||
# and overrides fly.toml env values | ||
ENV NODE_ENV production | ||
ENV NODE_OPTIONS="--max-old-space-size=320 --heapsnapshot-signal=SIGUSR2" | ||
# get working dir in order | ||
WORKDIR /app | ||
COPY --from=setup /node-dir/dist ./ | ||
COPY --from=setup /node-dir/blocklists__ ./blocklists__ | ||
COPY --from=setup /node-dir/dbip__ ./dbip__ | ||
# external deps not bundled by webpack | ||
RUN npm i @riaskov/[email protected] | ||
|
||
COPY --from=setup /app/dist ./ | ||
COPY --from=setup /app/blocklists__ ./blocklists__ | ||
COPY --from=setup /app/dbip__ ./dbip__ | ||
|
||
# print files in work dir, must contain blocklists | ||
RUN ls -Fla | ||
# run with the default entrypoint (usually, bash or sh) | ||
|
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
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
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
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
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