Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NEW Typescript Environment with Bun version 1.1.40 #418

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bun/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
18 changes: 18 additions & 0 deletions bun/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG BUN_BASE_IMG

FROM oven/bun:${BUN_BASE_IMG}

ARG BUN_ENV
ENV BUN_ENV $BUN_ENV

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app/
RUN bun install
COPY server.ts /usr/src/app/server.ts
COPY tsconfig.json /usr/src/app/tsconfig.json

CMD [ "bun", "run", "server.ts" ]

EXPOSE 8888
16 changes: 16 additions & 0 deletions bun/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-include ../rules.mk

.PHONY: all
all: bun-builder bun-env-img bun-env-debian-img bun-env-1140-img

bun-env-img-buildargs := --build-arg BUN_BASE_IMG=1.1.40-alpine

bun-env-debian-img-buildargs := --build-arg BUN_BASE_IMG=1.1.40

bun-env-1140-img-buildargs := --build-arg BUN_BASE_IMG=1.1.40-alpine

bun-env-img: Dockerfile

bun-env-debian-img: Dockerfile

bun-env-1140-img: Dockerfile
53 changes: 53 additions & 0 deletions bun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Fission: Bun Environment

This is the Bun environment for Fission.

It's a Docker image containing a Bun runtime, along with a dynamic
loader. A few common dependencies are included in the package.json
file.

Looking for ready-to-run examples? See the [Bun examples directory](../../examples/bun).

## Customizing this image

To add package dependencies, edit [package.json](./package.json) to add what you need, and rebuild this image (instructions below).

You also may want to customize what's available to the function in it's request context.
You can do this by editing [server.js](./server.js) (see the comment in that file about customizing request context).

## Rebuilding and pushing the image

You'll need access to a Docker registry to push the image: you can sign up for Docker hub at hub.docker.com, or use registries from gcr.io, quay.io, etc.
Let's assume you're using a docker hub account called USER.
Build and push the image to the the registry:

Building runtime image,

```console
docker build -t USER/bun-env --build-arg BUN_BASE_IMG=1.1.40-alpine -f Dockerfile .
docker push USER/bun-env
```

Building builder image,

```console
cd builder && docker build -t USER/bun-builder --build-arg BUN_BASE_IMG=1.1.40-alpine -f Dockerfile .
docker push USER/bun-builder
```

## Using the image in fission

You can add this customized image to fission with "fission env create":

```console
fission env create --name bun --image USER/bun-env
```

Or, if you already have an environment, you can update its image:

```console
fission env update --name bun --image USER/bun-env
```

After this, fission functions that have the env parameter set to the
same environment name as this command will use this environment.
13 changes: 13 additions & 0 deletions bun/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG BUN_BASE_IMG
ARG BUILDER_IMAGE=fission/builder:latest

FROM ${BUILDER_IMAGE}

FROM oven/bun:${BUN_BASE_IMG}

ARG BUN_ENV
ENV BUN_ENV $BUN_ENV

COPY --from=0 /builder /builder
ADD build.sh /usr/local/bin/build
RUN chmod +x /usr/local/bin/build
16 changes: 16 additions & 0 deletions bun/builder/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-include ../../rules.mk

.PHONY: all
all: bun-builder-debian-img bun-builder-img bun-builder-1140-img

bun-builder-debian-img-buildargs := --build-arg BUN_BASE_IMG=1.1.40

bun-builder-img-buildargs := --build-arg BUN_BASE_IMG=1.1.40-alpine

bun-builder-1140-img-buildargs := --build-arg BUN_BASE_IMG=1.1.40-alpine

bun-builder-debian-img: Dockerfile

bun-builder-img: Dockerfile

bun-builder-1140-img: Dockerfile
10 changes: 10 additions & 0 deletions bun/builder/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
cd ${SRC_PKG}

if [[ -n "$NPM_TOKEN" ]] && [[ -n "$NPM_REGISTRY" ]]; then
touch bunfig.toml
echo "[install.scopes]" >> bunfig.toml
echo "\"@private\" = { token = \"$NPM_TOKEN\", url = \"$NPM_REGISTRY\" }" >> bunfig.toml
fi

bun install && cp -r ${SRC_PKG} ${DEPLOY_PKG}
Binary file added bun/bun.lockb
Binary file not shown.
61 changes: 61 additions & 0 deletions bun/envconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[
{
"examples": "https://github.com/fission/environments/tree/master/bunjs/examples",
"icon": "./logo/bunjs-new-pantone-black.svg",
"image": "bun-env-debian",
"keywords": [],
"kind": "environment",
"maintainers": [
{
"link": "https://github.com/danhtran94",
"name": "danhtran94"
}
],
"name": "Bunjs Environment",
"readme": "https://github.com/fission/environments/tree/master/bunjs",
"runtimeVersion": "20.16.0-debian",
"shortDescription": "Fission Bunjs environment based on Express with some basic dependencies added",
"status": "Stable",
"version": "1.32.4"
},
{
"builder": "bun-builder-1140",
"examples": "https://github.com/fission/environments/tree/master/bunjs/examples",
"icon": "./logo/bunjs-new-pantone-black.svg",
"image": "bun-env-1140",
"keywords": [],
"kind": "environment",
"maintainers": [
{
"link": "https://github.com/danhtran94",
"name": "danhtran94"
}
],
"name": "Bunjs Environment",
"readme": "https://github.com/fission/environments/tree/master/bunjs",
"runtimeVersion": "22.6.0",
"shortDescription": "Fission Bunjs environment based on Express with some basic dependencies added",
"status": "Stable",
"version": "1.32.4"
},
{
"builder": "bun-builder",
"examples": "https://github.com/fission/environments/tree/master/bunjs/examples",
"icon": "./logo/bunjs-new-pantone-black.svg",
"image": "bun-env",
"keywords": [],
"kind": "environment",
"maintainers": [
{
"link": "https://github.com/danhtran94",
"name": "danhtran94"
}
],
"name": "Bunjs Environment",
"readme": "https://github.com/fission/environments/tree/master/bunjs",
"runtimeVersion": "20.16.0",
"shortDescription": "Fission Bunjs environment based on Express with some basic dependencies added",
"status": "Stable",
"version": "1.32.4"
}
]
32 changes: 32 additions & 0 deletions bun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "fission-bun-runtime",
"version": "0.1.0",
"author": "danhtran94",
"contributors": [
{
"name": "Tran Thanh Danh",
"email": "[email protected]"
}
],
"description": "BunJS run container for the fission framework",
"engines": {
},
"dependencies": {
"co": "~4.6.0",
"express": ">=4.0.0",
"minimist": "*",
"morgan": "*",
"mz": "~2.7.0",
"request": "^2.81.0",
"request-promise-native": "^1.0.3",
"underscore": ">=1.8.3",
"ws": "^7.5.5"
},
"devDependencies": {
"@types/bun": "^1.1.14",
"@types/express": "^5.0.0",
"@types/minimist": "^1.2.5",
"@types/morgan": "^1.9.9",
"@types/request": "^2.48.12"
}
}
Loading