Skip to content

Commit 0e563a4

Browse files
authored
Merge pull request #327 from DefangLabs/linda-nextjs-cv
Add Nextjs CV (from market.dev) sample
0 parents  commit 0e563a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+13949
-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]

.gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Node.js dependencies
2+
node_modules/
3+
4+
# Logs
5+
logs/
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
11+
# Temporary directories
12+
tmp/
13+
temp/
14+
dist/
15+
build/
16+
17+
# Compiled JavaScript
18+
*.d.ts
19+
*.js.map
20+
21+
# Compiled CSS
22+
*.css
23+
*.css.map
24+
25+
# IDE files
26+
.vscode/
27+
.idea/
28+
*.swp
29+
30+
# OS files
31+
.DS_Store
32+
Thumbs.db
33+
34+
# Environment variables
35+
.env
36+
37+
# Coverage reports
38+
coverage/
39+
40+
# Angular specific files
41+
.angular/
42+
.angular-cache/
43+
.sass-cache/
44+
45+
# Generated files
46+
*.class
47+
*.war
48+
*.ear
49+
50+
# NPM lock file
51+
package-lock.json
52+
53+
# Angular build outputs
54+
out-tsc/
55+
aot/
56+
app.out/
57+
vendor/
58+
59+
# Miscellaneous
60+
*.bak
61+
*.orig
62+
.angular
63+
64+
.gitkeep
65+
.editorconfig
66+
.DS_Store

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Angular & Node.js
2+
3+
[![1-click-deploy](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-angular-express-template%26template_owner%3DDefangSamples)
4+
5+
This sample demonstrates how to deploy a full-stack Angular and Node.js application with Defang. It uses Socket.IO for real-time communication. The Docker setup ensures the app can be easily built and deployed.
6+
7+
## Prerequisites
8+
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
11+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
12+
4. Install [Node.js](https://nodejs.org/en/download/package-manager/)
13+
5. Install [Angular CLI](https://angular.io/cli)
14+
15+
## Development
16+
For development, we use two local containers, one for the frontend Angular service and one for the backend service in Express. It also uses Caddy as a web server for serving static files.
17+
18+
To run the application locally, you can use the following command:
19+
20+
```bash
21+
docker compose -f compose.dev.yaml up --build
22+
```
23+
24+
## Configuration
25+
26+
For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration).
27+
28+
If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`.
29+
30+
```bash
31+
defang config set API_KEY
32+
```
33+
34+
## Deployment
35+
36+
> [!NOTE]
37+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
38+
39+
### Defang Playground
40+
41+
Deploy your application to the Defang Playground by opening up your terminal and typing:
42+
```bash
43+
defang compose up
44+
```
45+
46+
### BYOC (AWS)
47+
48+
If you want to deploy to your own cloud account, you can use Defang BYOC:
49+
50+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
51+
2. Run in a terminal that has access to your AWS environment variables:
52+
```bash
53+
defang --provider=aws compose up
54+
```
55+
56+
---
57+
58+
Title: Angular & Node.js
59+
60+
Short Description: A full-stack application using Angular for the frontend and Node.js with Socket.IO for the backend, containerized with Docker.
61+
62+
Tags: Angular, Node.js, Socket.IO, TypeScript, JavaScript
63+
64+
Languages: nodejs

backend/.dockerignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Dependency directories
2+
node_modules
3+
npm-debug.log
4+
5+
# Logs
6+
logs
7+
*.log
8+
9+
# Directory for output files
10+
dist
11+
tmp
12+
13+
# Environmental files
14+
.env
15+
16+
# Optional npm cache directory
17+
.npm
18+
19+
# Optional eslint cache
20+
.eslintcache
21+
22+
# Optional editor config files
23+
.editorconfig
24+
25+
# IDEs and editors
26+
.idea
27+
.vscode
28+
*.sublime*
29+
30+
# OS files
31+
.DS_Store
32+
Thumbs.db
33+
desktop.ini

backend/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use the slim version of Node.js v20 on Debian Bookworm as the base image
2+
FROM node:20-bookworm-slim
3+
4+
# Create and change to the app directory
5+
WORKDIR /app
6+
7+
# Copy application dependency manifests to the container image
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the local code to the container image
14+
COPY . .
15+
16+
# Expose the port the app runs on
17+
EXPOSE 3000
18+
19+
# Define the command to run your application
20+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)