Skip to content

Commit e798631

Browse files
committed
update deploy buttons
0 parents  commit e798631

File tree

22 files changed

+2553
-0
lines changed

22 files changed

+2553
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
FROM mcr.microsoft.com/devcontainers/typescript-node:22-bookworm

.devcontainer/devcontainer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile",
4+
"context": ".."
5+
},
6+
"features": {
7+
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
9+
"ghcr.io/devcontainers/features/aws-cli:1": {}
10+
}
11+
}

.github/workflows/deploy.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
environment: playground
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
steps:
17+
- name: Checkout Repo
18+
uses: actions/checkout@v4
19+
20+
- name: Deploy
21+
uses: DefangLabs/[email protected]

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Sveltekit
2+
3+
[![1-click-deploy](https://defang.io/deploy-with-defang.svg)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-sveltekit-template%26template_owner%3DDefangSamples)
4+
5+
This sample shows how to get a minimal SvelteKit app up and running with Defang.
6+
7+
## Prerequisites
8+
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. Have a managed database service configured and have the connection string ready.
11+
3. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS account
12+
4. (Optional - for local development) [Docker CLI](https://docs.docker.com/engine/install/)
13+
14+
## Development
15+
16+
To develop this app, you can run the sveltekit commands as you normally would on your local machine in the sveltekit directory. If you plan on adding other services, you might want to run it with docker compose. We have provided a `compose.dev.yaml` file and a `dev.Dockefile` to help you get started. Just run `docker compose -f compose.dev.yaml up --build` to start your Sveltekit app in dev mode in a container.
17+
18+
## Deploying
19+
20+
1. Open the terminal and type `defang login`
21+
2. Type `defang compose up` in the CLI.
22+
3. Your app will be running within a few minutes.
23+
24+
---
25+
26+
Title: SvelteKit
27+
28+
Short Description: A minimal SvelteKit app running on Defang.
29+
30+
Tags: SvelteKit, TypeScript, JavaScript, Svelte, Node.js, Frontend, TypeScript, JavaScript
31+
32+
Languages: nodejs

compose.dev.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
sveltekit:
3+
build:
4+
context: ./sveltekit
5+
dockerfile: dev.Dockerfile
6+
volumes:
7+
- ./sveltekit:/app
8+
- /app/node_modules
9+
ports:
10+
- target: 3000
11+
mode: ingress
12+
published: 3000
13+
command: npm run dev -- --port 3000 --host 0.0.0.0

compose.yaml

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

sveltekit/.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Ignore node modules
2+
node_modules
3+
4+
# Ignore .svelte-kit folder
5+
.svelte-kit
6+
7+
# Ignore build output
8+
build
9+
10+
# Ignore .env files
11+
.env*
12+
13+
# Ignore logs
14+
*.log
15+
16+
# Ignore the npm debug log
17+
npm-debug.log*
18+
19+
# Ignore IDE specific files
20+
.idea
21+
.vscode
22+
*.swp
23+
*.swo
24+
25+
# Ignore OS specific files
26+
.DS_Store
27+
Thumbs.db

sveltekit/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
node_modules
3+
/build
4+
/.svelte-kit
5+
/package
6+
.env
7+
.env.*
8+
!.env.example
9+
vite.config.js.timestamp-*
10+
vite.config.ts.timestamp-*

sveltekit/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

sveltekit/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Stage 1: Build the application
2+
FROM node:20-bookworm-slim as build
3+
4+
WORKDIR /app
5+
6+
# Copy package.json and package-lock.json
7+
COPY package.json package-lock.json ./
8+
9+
# Install dependencies
10+
RUN npm ci
11+
12+
# Copy the rest of the application code
13+
COPY . .
14+
15+
# Build the application
16+
RUN npm run build
17+
18+
# List the contents of the build directory for verification
19+
RUN ls -l .svelte-kit/output
20+
21+
# Stage 2: Run the application
22+
FROM node:20-bookworm-slim
23+
24+
WORKDIR /app
25+
26+
# Copy the built application and package files from the build stage
27+
COPY --from=build /app/build ./build
28+
COPY --from=build /app/package.json /app/package-lock.json ./
29+
30+
# Install production dependencies only
31+
RUN npm ci --omit=dev
32+
33+
# Expose the application port
34+
EXPOSE 3000
35+
36+
# Command to run the application
37+
CMD ["node", "build"]

0 commit comments

Comments
 (0)