From cd39cf392ea01ff9e0787fb62816c39ae3ded839 Mon Sep 17 00:00:00 2001 From: linda Date: Tue, 3 Sep 2024 10:55:30 -0700 Subject: [PATCH 1/4] Fixed typo on Flask sample --- samples/flask/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/flask/README.md b/samples/flask/README.md index de203335..91e695e0 100644 --- a/samples/flask/README.md +++ b/samples/flask/README.md @@ -31,7 +31,7 @@ This sample is a simple Flask app that demonstrates how to create a TODO app usi Title: Flask -Short Description: A basic Flask to o app. +Short Description: A basic Flask to do app. Tags: Flask, Python From 5c2ff485b86acccdb6555460524b14eaeaf614bf Mon Sep 17 00:00:00 2001 From: linda Date: Thu, 26 Sep 2024 09:50:07 -0700 Subject: [PATCH 2/4] Added new html-css-js sample --- .../html-css-js/.github/workflows/deploy.yaml | 20 +++++++++++ samples/html-css-js/README.md | 36 +++++++++++++++++++ samples/html-css-js/app/.dockerignore | 0 samples/html-css-js/app/.gitignore | 0 samples/html-css-js/app/Dockerfile | 18 ++++++++++ samples/html-css-js/app/index.html | 15 ++++++++ samples/html-css-js/app/nginx.conf | 15 ++++++++ samples/html-css-js/app/page2.html | 15 ++++++++ samples/html-css-js/app/script.js | 1 + samples/html-css-js/app/style.css | 13 +++++++ samples/html-css-js/compose.yaml | 18 ++++++++++ 11 files changed, 151 insertions(+) create mode 100644 samples/html-css-js/.github/workflows/deploy.yaml create mode 100644 samples/html-css-js/README.md create mode 100644 samples/html-css-js/app/.dockerignore create mode 100644 samples/html-css-js/app/.gitignore create mode 100644 samples/html-css-js/app/Dockerfile create mode 100644 samples/html-css-js/app/index.html create mode 100644 samples/html-css-js/app/nginx.conf create mode 100644 samples/html-css-js/app/page2.html create mode 100644 samples/html-css-js/app/script.js create mode 100644 samples/html-css-js/app/style.css create mode 100644 samples/html-css-js/compose.yaml diff --git a/samples/html-css-js/.github/workflows/deploy.yaml b/samples/html-css-js/.github/workflows/deploy.yaml new file mode 100644 index 00000000..84d3dcf4 --- /dev/null +++ b/samples/html-css-js/.github/workflows/deploy.yaml @@ -0,0 +1,20 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Deploy + uses: DefangLabs/defang-github-action@v1.0.4 \ No newline at end of file diff --git a/samples/html-css-js/README.md b/samples/html-css-js/README.md new file mode 100644 index 00000000..01b27484 --- /dev/null +++ b/samples/html-css-js/README.md @@ -0,0 +1,36 @@ +# HTML & CSS & JavaScript + +[1-click deploy](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample--template%26template_owner%3DDefangSamples) + +This sample shows how to get a static HTML + CSS + JavaScript website up and running with Defang. + +## Prerequisites + +1. Download [Defang CLI](https://github.com/DefangLabs/defang) +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 +3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/) + +## Development + +To run the application locally, you can use the following command: + +```bash +docker compose up +``` + +## Deploying + +1. Open the terminal and type `defang login` +2. Use the [`defang config`](https://docs.defang.io/docs/concepts/compose#configuration) command to setup environment variables. #REMOVE_ME_AFTER_EDITING +3. Type `defang compose up` in the CLI. +4. Your app will be running within a few minutes. + +--- + +Title: HTML & CSS & JavaScript + +Short Description: A simple HTML + CSS + JavaScript website running on Defang. + +Tags: HTML, CSS, JavaScript, Frontend + +Languages: HTML, CSS, JavaScript diff --git a/samples/html-css-js/app/.dockerignore b/samples/html-css-js/app/.dockerignore new file mode 100644 index 00000000..e69de29b diff --git a/samples/html-css-js/app/.gitignore b/samples/html-css-js/app/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/samples/html-css-js/app/Dockerfile b/samples/html-css-js/app/Dockerfile new file mode 100644 index 00000000..8bdf0659 --- /dev/null +++ b/samples/html-css-js/app/Dockerfile @@ -0,0 +1,18 @@ +# Use nginx as the base image +FROM nginx:alpine + +# Set working directory to /app +WORKDIR /app + +# Copy project files to nginx directory +COPY . /usr/share/nginx/html + +# Set correct permissions for the project files +RUN chmod -R 755 /usr/share/nginx/html && chown -R nginx:nginx /usr/share/nginx/html + +# Copy the config file to nginx directory +COPY nginx.conf /etc/nginx/nginx.conf + +# Expose the port your app runs on +EXPOSE 80 + diff --git a/samples/html-css-js/app/index.html b/samples/html-css-js/app/index.html new file mode 100644 index 00000000..f17ac8f1 --- /dev/null +++ b/samples/html-css-js/app/index.html @@ -0,0 +1,15 @@ + + + + + + HTML Sample + + + + +

Welcome to Defang!

+

Start developing with our samples.

+ + + \ No newline at end of file diff --git a/samples/html-css-js/app/nginx.conf b/samples/html-css-js/app/nginx.conf new file mode 100644 index 00000000..f2c84263 --- /dev/null +++ b/samples/html-css-js/app/nginx.conf @@ -0,0 +1,15 @@ +http { + include mime.types; + sendfile on; + server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html; + } + } +} + +events {} \ No newline at end of file diff --git a/samples/html-css-js/app/page2.html b/samples/html-css-js/app/page2.html new file mode 100644 index 00000000..578e57b4 --- /dev/null +++ b/samples/html-css-js/app/page2.html @@ -0,0 +1,15 @@ + + + + + + Page 2 of HTML Sample + + + + +

Cloud, Simplified!

+

Having fun? For more, go to our official website at defang.io!

+ + + \ No newline at end of file diff --git a/samples/html-css-js/app/script.js b/samples/html-css-js/app/script.js new file mode 100644 index 00000000..63a5d43e --- /dev/null +++ b/samples/html-css-js/app/script.js @@ -0,0 +1 @@ +// Add your Javascript code here \ No newline at end of file diff --git a/samples/html-css-js/app/style.css b/samples/html-css-js/app/style.css new file mode 100644 index 00000000..fee069e1 --- /dev/null +++ b/samples/html-css-js/app/style.css @@ -0,0 +1,13 @@ +body { + background-color: #ffffff; +} + +h1 { + color: #0F71BE; +} + +p { + color: #28A2E9; +} + +/* Add more CSS styling */ \ No newline at end of file diff --git a/samples/html-css-js/compose.yaml b/samples/html-css-js/compose.yaml new file mode 100644 index 00000000..a964b705 --- /dev/null +++ b/samples/html-css-js/compose.yaml @@ -0,0 +1,18 @@ +services: + app: + # uncomment to add your own domain + # domainname: example.com + restart: unless-stopped + build: + context: ./app + dockerfile: Dockerfile + ports: + - target: 80 + published: 8080 + mode: ingress + deploy: + resources: + reservations: + memory: 256M + healthcheck: + test: ["CMD", "wget", "-q", "--spider", "http://localhost:80/"] \ No newline at end of file From f2fae1ed80b315ca1569d508138c1c211f44e11d Mon Sep 17 00:00:00 2001 From: commit111 Date: Thu, 26 Sep 2024 10:10:26 -0700 Subject: [PATCH 3/4] edited readme --- samples/html-css-js/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/html-css-js/README.md b/samples/html-css-js/README.md index 01b27484..127acd2f 100644 --- a/samples/html-css-js/README.md +++ b/samples/html-css-js/README.md @@ -21,9 +21,8 @@ docker compose up ## Deploying 1. Open the terminal and type `defang login` -2. Use the [`defang config`](https://docs.defang.io/docs/concepts/compose#configuration) command to setup environment variables. #REMOVE_ME_AFTER_EDITING -3. Type `defang compose up` in the CLI. -4. Your app will be running within a few minutes. +2. Type `defang compose up` in the CLI. +3. Your app will be running within a few minutes. --- From 50655d7d69a56ad0754709999a72faee32527a0a Mon Sep 17 00:00:00 2001 From: commit111 Date: Fri, 27 Sep 2024 15:59:55 -0700 Subject: [PATCH 4/4] got rid of angled brackets in readme --- samples/html-css-js/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/html-css-js/README.md b/samples/html-css-js/README.md index 127acd2f..e8b5d26b 100644 --- a/samples/html-css-js/README.md +++ b/samples/html-css-js/README.md @@ -1,6 +1,6 @@ # HTML & CSS & JavaScript -[1-click deploy](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample--template%26template_owner%3DDefangSamples) +[1-click deploy](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-html-css-js-template%26template_owner%3DDefangSamples) This sample shows how to get a static HTML + CSS + JavaScript website up and running with Defang.