Skip to content

Commit 3a28668

Browse files
authored
Merge pull request #459 from commit111/linda-redis-js
Redis-JavaScript Sample
2 parents 371442d + a0d65ce commit 3a28668

File tree

12 files changed

+1162
-0
lines changed

12 files changed

+1162
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mcr.microsoft.com/devcontainers/typescript-node:22-bookworm
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+
}
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]

samples/redis-js/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Redis & JavaScript
2+
[![1-click-deploy](https://raw.githubusercontent.com/DefangLabs/defang-assets/main/Logos/Buttons/SVG/deploy-with-defang.svg)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-redis-js-template%26template_owner%3DDefangSamples)
3+
4+
This is a Redis and JavaScript application, deployed with Defang.
5+
6+
Note that Defang supports the use of managed Redis in production deployments. You can enable this feature by adding the `x-defang-redis: true` tag to your Redis service in the `compose.yaml` file.
7+
8+
## Prerequisites
9+
10+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
11+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
12+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
13+
14+
## Development
15+
16+
To run the application locally, you can use the following command:
17+
18+
```bash
19+
docker compose up --build
20+
```
21+
22+
## Deployment
23+
24+
> [!NOTE]
25+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
26+
27+
### Defang Playground
28+
29+
Deploy your application to the Defang Playground by opening up your terminal and typing:
30+
```bash
31+
defang compose up
32+
```
33+
34+
### BYOC
35+
36+
If you want to deploy to your own cloud account, you can [use Defang BYOC](https://docs.defang.io/docs/tutorials/deploy-to-your-cloud).
37+
38+
---
39+
40+
Title: Redis & JavaScript
41+
42+
Short Description: A Redis and JavaScript application, deployed with Defang.
43+
44+
Tags: Redis, JavaScript
45+
46+
Languages: JavaScript

samples/redis-js/app/.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Default .dockerignore file for Defang
2+
**/__pycache__
3+
**/.direnv
4+
**/.DS_Store
5+
**/.envrc
6+
**/.git
7+
**/.github
8+
**/.idea
9+
**/.next
10+
**/.vscode
11+
**/compose.*.yaml
12+
**/compose.*.yml
13+
**/compose.yaml
14+
**/compose.yml
15+
**/docker-compose.*.yaml
16+
**/docker-compose.*.yml
17+
**/docker-compose.yaml
18+
**/docker-compose.yml
19+
**/node_modules
20+
**/Thumbs.db
21+
Dockerfile
22+
*.Dockerfile
23+
# Ignore our own binary, but only in the root to avoid ignoring subfolders
24+
defang
25+
defang.exe
26+
# Ignore our project-level state
27+
.defang

samples/redis-js/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

samples/redis-js/app/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use Node.js as the base image
2+
FROM node:22-alpine
3+
4+
# Set working directory to /app
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json first for better caching
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the project files
14+
COPY . .
15+
16+
# Expose the port your app runs on
17+
EXPOSE 3000
18+
19+
# Start the Node.js app
20+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)