-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
11 changed files
with
255 additions
and
120 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
####################################### | ||
# | ||
# Build Stage | ||
# | ||
####################################### | ||
FROM golang:1.20-alpine AS build-stage | ||
|
||
ENV ESM_SH_VERSION v127 | ||
ENV ESM_SH_GIT_URL https://github.com/esm-dev/esm.sh | ||
|
||
RUN apk add --no-cache git | ||
RUN git clone --branch $ESM_SH_VERSION --depth 1 $ESM_SH_GIT_URL /tmp/esm.sh | ||
|
||
WORKDIR /tmp/esm.sh | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o esmd main.go | ||
|
||
####################################### | ||
# | ||
# Release Stage | ||
# | ||
####################################### | ||
FROM node:18-alpine AS release-stage | ||
|
||
RUN apk update && apk add --no-cache libcap-utils | ||
RUN npm i -g pnpm | ||
|
||
COPY --from=build-stage /tmp/esm.sh/esmd /bin/esmd | ||
RUN setcap cap_net_bind_service=ep /bin/esmd | ||
RUN chown node:node /bin/esmd | ||
|
||
USER node | ||
WORKDIR / | ||
EXPOSE 8080 | ||
CMD ["esmd"] |
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,39 @@ | ||
name: Docker push dev | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
dev: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GHCR | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: esm-dev/esm.sh:dev |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,7 +328,7 @@ rebuild: | |
func(args api.OnResolveArgs) (api.OnResolveResult, error) { | ||
if strings.HasPrefix(args.Path, "file:") { | ||
return api.OnResolveResult{ | ||
Path: fmt.Sprintf("%s/error.js?type=unsupported-file-dependency&name=%s&importer=%s", cfg.BasePath, strings.TrimPrefix(args.Path, "file:"), task.Pkg), | ||
Path: fmt.Sprintf("%s/error.js?type=unsupported-file-dependency&name=%s&importer=%s", cfg.CdnBasePath, strings.TrimPrefix(args.Path, "file:"), task.Pkg), | ||
External: true, | ||
}, nil | ||
} | ||
|
@@ -441,7 +441,7 @@ rebuild: | |
} | ||
} | ||
return api.OnResolveResult{ | ||
Path: fmt.Sprintf("%s/error.js?type=unsupported-npm-package&name=%s&importer=%s", cfg.BasePath, specifier, task.Pkg), | ||
Path: fmt.Sprintf("%s/error.js?type=unsupported-npm-package&name=%s&importer=%s", cfg.CdnBasePath, specifier, task.Pkg), | ||
External: true, | ||
}, nil | ||
} | ||
|
@@ -456,7 +456,7 @@ rebuild: | |
|
||
if strings.HasSuffix(fullFilepath, ".node") && fileExists(fullFilepath) { | ||
return api.OnResolveResult{ | ||
Path: fmt.Sprintf("%s/error.js?type=unsupported-node-native-module&name=%s&importer=%s", cfg.BasePath, path.Base(args.Path), task.Pkg), | ||
Path: fmt.Sprintf("%s/error.js?type=unsupported-node-native-module&name=%s&importer=%s", cfg.CdnBasePath, path.Base(args.Path), task.Pkg), | ||
External: true, | ||
}, nil | ||
} | ||
|
@@ -735,7 +735,7 @@ rebuild: | |
} else if task.Target == "deno" { | ||
fmt.Fprintf(header, `import __Process$ from "https://deno.land/std@%s/node/process.ts";%s`, task.Args.denoStdVersion, EOL) | ||
} else { | ||
fmt.Fprintf(header, `import __Process$ from "%s/v%d/node_process.js";%s`, cfg.BasePath, task.BuildVersion, EOL) | ||
fmt.Fprintf(header, `import __Process$ from "%s/v%d/node_process.js";%s`, cfg.CdnBasePath, task.BuildVersion, EOL) | ||
} | ||
} | ||
if ids.Has("__Buffer$") { | ||
|
@@ -744,7 +744,7 @@ rebuild: | |
} else if task.Target == "deno" { | ||
fmt.Fprintf(header, `import { Buffer as __Buffer$ } from "https://deno.land/std@%s/node/buffer.ts";%s`, task.Args.denoStdVersion, EOL) | ||
} else { | ||
fmt.Fprintf(header, `import { Buffer as __Buffer$ } from "%s/v%d/[email protected]/%s/buffer.mjs";%s`, cfg.BasePath, task.BuildVersion, task.Target, EOL) | ||
fmt.Fprintf(header, `import { Buffer as __Buffer$ } from "%s/v%d/[email protected]/%s/buffer.mjs";%s`, cfg.CdnBasePath, task.BuildVersion, task.Target, EOL) | ||
} | ||
} | ||
if ids.Has("__global$") { | ||
|
@@ -910,11 +910,11 @@ func (task *BuildTask) resolveExternal(specifier string, kind api.ResolveKind) s | |
} else { | ||
_, err := embedFS.ReadFile(fmt.Sprintf("server/embed/polyfills/node_%s.js", specifier)) | ||
if err == nil { | ||
importPath = fmt.Sprintf("%s/v%d/node_%s.js", cfg.BasePath, task.BuildVersion, specifier) | ||
importPath = fmt.Sprintf("%s/v%d/node_%s.js", cfg.CdnBasePath, task.BuildVersion, specifier) | ||
} else { | ||
importPath = fmt.Sprintf( | ||
"%s/error.js?type=unsupported-node-builtin-module&name=%s&importer=%s", | ||
cfg.BasePath, | ||
cfg.CdnBasePath, | ||
specifier, | ||
task.Pkg, | ||
) | ||
|
@@ -961,7 +961,7 @@ func (task *BuildTask) resolveExternal(specifier string, kind api.ResolveKind) s | |
importPath = jsDataUrl(`export const AbortSignal=globalThis.AbortSignal;export const AbortController=globalThis.AbortController;export default AbortController`) | ||
case "node-fetch": | ||
if task.Target != "node" { | ||
importPath = fmt.Sprintf("%s/v%d/node_fetch.js", cfg.BasePath, task.BuildVersion) | ||
importPath = fmt.Sprintf("%s/v%d/node_fetch.js", cfg.CdnBasePath, task.BuildVersion) | ||
} | ||
} | ||
} | ||
|
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
Oops, something went wrong.