Skip to content

Commit 672242e

Browse files
authored
Merge pull request #63 from DefangLabs/25-elysia-sample
Elysia Sample
2 parents 4742544 + c6715e0 commit 672242e

File tree

12 files changed

+300
-0
lines changed

12 files changed

+300
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- pr-test/*
8+
9+
concurrency:
10+
group: deploy
11+
cancel-in-progress: false
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout Repo
21+
uses: actions/checkout@v4
22+
23+
- name: Install defang
24+
run: . <(curl -Ls https://s.defang.io/install)
25+
26+
- name: Login to Defang
27+
run: defang login
28+
29+
- name: Deploy
30+
run: defang compose up -v --detach

samples/elysia/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Elysia × Bun × Defang
2+
3+
A basic [Elysia](https://elysiajs.com/) app running on [Bun](https://bun.sh/) with a Dockerfile and compose.yaml ready to deploy to AWS with [Defang](https://defang.io).
4+
5+
6+
## Prerequisites
7+
8+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
9+
2. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS account
10+
3. (Optional - for local development) [Docker CLI](https://docs.docker.com/engine/install/)
11+
12+
13+
## Deploying
14+
15+
1. Run `defang login` if you are not yet logged in.
16+
4. Run `defang compose up`.
17+
5. Your app will be running within a few minutes.
18+
19+
20+
## Local Development
21+
22+
1. Run `docker compose -f compose.dev.yaml up`
23+
24+
25+
---
26+
27+
Title: Elysia × Bun × Defang
28+
29+
Short Description: A basic Elysia app running on Bun with Defang.
30+
31+
Tags: bun, elysia, typescript
32+
33+
Languages: typescript

samples/elysia/compose.dev.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
name: elysia
3+
services:
4+
elysia:
5+
extends:
6+
file: compose.yaml
7+
service: elysia
8+
volumes:
9+
- ./elysia:/app
10+
- /app/node_modules
11+
command: bun dev

samples/elysia/compose.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3'
2+
name: elysia
3+
services:
4+
elysia:
5+
restart: unless-stopped
6+
# domainname: mydomain.com # if you want to use your own domain
7+
build:
8+
context: ./elysia
9+
dockerfile: Dockerfile
10+
target: production
11+
ports:
12+
- target: 3000
13+
mode: ingress
14+
published: 3000
15+
deploy:
16+
resources:
17+
limits:
18+
cpus: '0.50'
19+
memory: 512M
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

samples/elysia/elysia/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
35+
36+
**/*.trace
37+
**/*.zip
38+
**/*.tar.gz
39+
**/*.tgz
40+
**/*.log
41+
package-lock.json
42+
**/*.bun

samples/elysia/elysia/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM oven/bun:1.1-slim as bun-base
2+
3+
WORKDIR /app
4+
5+
COPY package.json bun.lockb ./
6+
RUN bun install
7+
8+
9+
FROM bun-base as production
10+
11+
COPY package.json bun.lockb ./
12+
RUN bun install --production
13+
14+
COPY src src
15+
COPY tsconfig.json ./
16+
17+
ENV NODE_ENV=production
18+
19+
CMD [ "bun", "src/index.ts" ]

samples/elysia/elysia/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Elysia with Bun runtime
2+
3+
## Getting Started
4+
To get started with this template, simply paste this command into your terminal:
5+
```bash
6+
bun create elysia ./elysia-example
7+
```
8+
9+
## Development
10+
To start the development server run:
11+
```bash
12+
bun run dev
13+
```
14+
15+
Open http://localhost:3000/ with your browser to see the result.

samples/elysia/elysia/bun.lockb

4.84 KB
Binary file not shown.

samples/elysia/elysia/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "app",
3+
"version": "1.0.50",
4+
"scripts": {
5+
"test": "echo \"Error: no test specified\" && exit 1",
6+
"dev": "bun run --watch src/index.ts"
7+
},
8+
"dependencies": {
9+
"elysia": "latest"
10+
},
11+
"devDependencies": {
12+
"bun-types": "latest"
13+
},
14+
"module": "src/index.js"
15+
}

0 commit comments

Comments
 (0)