Skip to content

Commit

Permalink
Merge pull request #159 from DefangLabs/revert-137-jordan/deduplicate…
Browse files Browse the repository at this point in the history
…-samples

Revert "deduplicate samples from docs site in favour of mktg site"
  • Loading branch information
jordanstephens authored Jan 8, 2025
2 parents 60c7df1 + 3099df5 commit 62b02e4
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 55 deletions.
2 changes: 1 addition & 1 deletion blog/2024-02-12-announcing-defang-public-beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Ever since we shipped our Private Beta in the summer of 2023, we have been worki

And so, today with our Public Beta, we are addressing this request. With today’s release of [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) (Bring-your-own-Cloud), you can now enjoy all the benefits of Defang **and** deploy applications to your own AWS account! Our Private Beta experience is still available as [Defang Playground](https://docs.defang.io/docs/concepts/defang-playground) for you to quickly and easily prototype applications and deploy them to our hosted environment.

You can learn more about Defang [here](https://docs.defang.io/docs/intro). Also check out our [tutorials](https://docs.defang.io/docs/category/tutorials), [samples](https://defang.io/#samples), and [FAQ](https://docs.defang.io/docs/category/faq) to know more.
You can learn more about Defang [here](https://docs.defang.io/docs/intro). Also check out our [tutorials](https://docs.defang.io/docs/category/tutorials), [samples](https://docs.defang.io/docs/samples), and [FAQ](https://docs.defang.io/docs/category/faq) to know more.

**Try the Public Beta!**

Expand Down
13 changes: 7 additions & 6 deletions blog/2024-07-31-july-product-updates-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ Hey folks! We can’t believe a month has gone by already, time flies when you

1. As our user-base grows, we wanted to make sure we’re able to scale our [Playground](https://docs.defang.io/docs/concepts/defang-playground) environment to be able to handle the load. This involved being able to shard the workload across multiple ALBs and being able to dynamically move some workloads across shards where possible. With these changes, we are now able handle a large number of concurrent users comfortably. The only noticeable change in behavior you would see is that Defang will now ask you to “`compose down`” your previous project before you are able to deploy a new project on Playground.

2. The major news this month was the introduction of our “`debug`” functionality. The motivation for this feature was that while the Defang experience is amazing when everything goes smoothly, we saw users (including our own interns who are helping write all those [samples](https://defang.io/#samples)) struggle when they hit an error. The underlying reason for the error could come from a variety of sources: an error in the developer’s application (including in their Dockerfile or Compose file), an issue in the way Defang is processing the application, or an issue in the underlying cloud platform (currently, AWS). To the developer, it is often not obvious what the issue is or how to fix it. That got us thinking how we could make this debugging experience “radically simpler” and thus the idea for `defang debug` was born.

2. The major news this month was the introduction of our “`debug`” functionality. The motivation for this feature was that while the Defang experience is amazing when everything goes smoothly, we saw users (including our own interns who are helping write all those [samples](https://docs.defang.io/docs/samples)) struggle when they hit an error. The underlying reason for the error could come from a variety of sources: an error in the developer’s application (including in their Dockerfile or Compose file), an issue in the way Defang is processing the application, or an issue in the underlying cloud platform (currently, AWS). To the developer, it is often not obvious what the issue is or how to fix it. That got us thinking how we could make this debugging experience “radically simpler” and thus the idea for `defang debug` was born.
Now (with CLI v0.5.37 if your application encounters an error that leads to a failed deployment, a failed health-check, or a run-time error, Defang will automatically detect the issue. It will then offer to help you debug it by running the `defang debug` command. If you choose to proceed, Defang will apply an LLM model to try to determine the precise cause of the error, with the context of your application source, logs, error code etc. And it will try to come up with one or more actionable insights on how to fix the error. For an example, see the case below:



Behind the scenes, Defang is having a conversation on your behalf with the LLM to narrow down to the cause of the error. We would love for you to try the `debug` feature and give us your feedback so we can improve it further. One future improvement already on our list is the ability to, with user consent, automatically apply a chosen fix and re-try. We are also looking for way to improve the range of failures we are able to diagnose successfully.

## Townhall

If you're excited about what's coming next and want to hear more about our vision for the future, join us for our Townhall on August 21st. We'll be sharing more about our roadmap and what we're working on next. We'll also be making sure to take time to answer any questions you have, hear your feedback, and learn more about what you want from Defang!

**[Register here](https://lu.ma/rlj13eq5)**

---

We’re excited to keep improving Defang to make it the easiest way for you to Develop, Deploy, and Debug cloud application. Stay tuned for more updates next month.

2 changes: 1 addition & 1 deletion docs/intro/features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Defang provides a streamlined experience to develop, deploy, and debug your clou

### Wide Variety of Use Cases
- Support for [various types of applications](/docs/intro/use-cases): web services and APIs, mobile app backends, ML services, hosting LLMs, etc...
- Support for your programming [language of choice](https://defang.io/#samples): Node.js, Python, Golang, or anything else you can package in a Dockerfile
- Support for your programming [language of choice](/docs/samples): Node.js, Python, Golang, or anything else you can package in a Dockerfile

### AI-Driven Features
- Built-in AI agent to go [from natural language prompt to an outline project](/docs/tutorials/generate-new-code-using-ai)
Expand Down
15 changes: 15 additions & 0 deletions docs/samples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Samples
description: Sample projects to help you launch services faster with Defang.
sidebar_position: 600
---

import {Button, ButtonGroup, FormGroup, FormLabel} from "@mui/material"

# Samples

Check out our sample projects here to get some inspiration and get a sense of how Defang works.

import Samples from "../src/components/Samples";

<Samples />
19 changes: 2 additions & 17 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const { themes } = require('prism-react-renderer');
const {themes} = require('prism-react-renderer');
const lightCodeTheme = themes.github;
const darkCodeTheme = themes.dracula;

const redirects = [
{
from: '/docs/samples',
to: 'https://defang.io/#samples',
},
];

/** @type {import('@docusaurus/types').DocusaurusConfig} */
const config = {
scripts: [
Expand Down Expand Up @@ -163,15 +156,7 @@ const config = {
darkTheme: darkCodeTheme,
},
},
plugins: [
require.resolve('docusaurus-lunr-search'),
[
'@docusaurus/plugin-client-redirects',
{
redirects,
},
],
],
plugins: [require.resolve('docusaurus-lunr-search')],
};

module.exports = config;
25 changes: 0 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"dependencies": {
"@docusaurus/core": "3.0.0",
"@docusaurus/plugin-client-redirects": "3.0.0",
"@docusaurus/preset-classic": "3.0.0",
"@docusaurus/theme-common": "3.0.0",
"@emotion/react": "^11.11.1",
Expand Down
6 changes: 6 additions & 0 deletions scripts/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ if [ -d "../defang" ]; then
else
DEFANG_PATH=$(readlink -f ./defang)
fi
if [ -d "../samples" ]; then
SAMPLES_PATH=$(readlink -f ../samples)
else
SAMPLES_PATH=$(readlink -f ./samples)
fi

cd "$DEFANG_PATH/src/cmd/gendocs" && go run main.go "$CLI_DOCS_PATH"
cd "$CWD"
node scripts/prep-cli-docs.js
node scripts/prep-samples.js "$SAMPLES_PATH/samples"
93 changes: 93 additions & 0 deletions scripts/prep-samples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const fs = require('fs');
const path = require('path');
const YAML = require('yaml');

const samplesDir = process.argv[2];

// categories are directories in the current directory (i.e. we're running in samples/ and we might have a samples/ruby/ directory)
const directories = fs.readdirSync(samplesDir).filter(file => fs.statSync(path.join(samplesDir, file)).isDirectory());

let jsonArray = [];

directories.forEach((sample) => {
const directoryName = sample;
console.log(`@@ Adding ${sample}`);
let readme;
try {
readme = fs.readFileSync(path.join(samplesDir, sample, 'README.md'), 'utf8');
} catch (error) {
readme = `# ${sample}`;
}

// The readme should contain lines that start with the following:
// Title:
// Short Description:
// Tags:
// Languages:
//
// We want to extract the title, short description, tags, and languages from the readme. Tags and languages are comma separated lists.
const title = readme.match(/Title: (.*)/)[1];
const shortDescription = readme.match(/Short Description: (.*)/)[1];
const tags = readme.match(/Tags: (.*)/)[1].split(',').map(tag => tag.trim());
const languages = readme.match(/Languages: (.*)/)[1].split(',').map(language => language.trim());

let configs = [];
try {
composeFile = fs.readFileSync(path.join(samplesDir, sample, 'compose.yaml'), 'utf8');
compose = YAML.parse(composeFile);

for (var name in compose.services) {
service = compose.services[name]
if (Array.isArray(service.environment)) {
service.environment.forEach(env => {
if (!env.includes("=")) {
configs.push(env);
}
});
} else {
for (var name in service.environment) {
value = service.environment[name];
if (value === null || value === undefined || value === "") {
configs.push(name);
}
}
}
}
} catch (error) {
// Ignore if the sample doesn't have a compose file
if (error.code != 'ENOENT') {
console.log(`failed to parese compose for configs for sample`, sample, error);
}
}

const sampleSummary = {
name: directoryName,
category: languages?.[0],
readme,
directoryName,
title,
shortDescription,
tags,
languages,
};
if (configs.length > 0) {
sampleSummary.configs = configs;
}
jsonArray.push(sampleSummary);

console.log(`@@ Added ${sample}`);
});

const stringified = JSON.stringify(jsonArray, null, 2);

// fs.writeFileSync(path.join(__dirname, '..', 'samples.json'), stringified);

// we're going to open up the ../docs/samples.md file and replce [] with the stringified JSON

// const samplesMd = path.join(__dirname, '..', 'docs', 'samples.md');
// let samplesMdContents = fs.readFileSync(samplesMd, 'utf8');
// samplesMdContents += `<Samples samples={${stringified}} />`;
// fs.writeFileSync(samplesMd, samplesMdContents);

// save the json to the samples.json file in static
fs.writeFileSync(path.join(__dirname, '..', 'static', 'samples-v2.json'), stringified);
5 changes: 1 addition & 4 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
// By default, Docusaurus generates a sidebar from the docs folder structure
docsSidebar: [
{type: 'autogenerated', dirName: '.'},
{ type: 'link', label: 'Samples', href: 'https://defang.io/#samples' },
],
docsSidebar: [{type: 'autogenerated', dirName: '.'}],
};

module.exports = sidebars;
Loading

0 comments on commit 62b02e4

Please sign in to comment.