-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
243 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,123 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
# ❍ | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
- **10x faster** deploys | ||
- Native **multi-region** support | ||
- No more cyclical dependencies | ||
- No stacks or stack resource limits | ||
- No CDK or npm package conflicts | ||
- Native support for **non-AWS** providers | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun dev | ||
[Read the full announcement here](https://sst.dev/blog/moving-away-from-cdk.html). | ||
|
||
_Note: Ion is currently in alpha and only supports deploying Next.js sites and L1 AWS resources. We'll be sharing docs and technical details soon._ | ||
|
||
## Installation | ||
|
||
### curl | ||
sst can be installed using a simple curl command | ||
``` | ||
curl -fsSL https://ion.sst.dev/install | bash | ||
``` | ||
|
||
#### macOS | ||
|
||
`sst` is available via a Homebrew Tap, and as downloadable binary from the [releases](https://github.com/sst/ion/releases/latest) page: | ||
|
||
``` | ||
brew install sst/tap/sst | ||
``` | ||
|
||
To upgrade to the latest version: | ||
|
||
``` | ||
brew upgrade sst | ||
``` | ||
|
||
You might have to run `brew update` before upgrading. | ||
|
||
#### Linux | ||
|
||
`sst` is available as downloadable binaries from the [releases](https://github.com/sst/ion/releases/latest) page. Download the .deb or .rpm from the [releases](https://github.com/sst/ion/releases/latest) page and install with `sudo dpkg -i` and `sudo rpm -i` respectively. | ||
|
||
For arch linux it's available in the [aur](https://aur.archlinux.org/packages/sst-bin) | ||
|
||
#### Windows | ||
|
||
`sst` is available via [scoop](https://scoop.sh/), and as a downloadable binary from the [releases](https://github.com/sst/ion/releases/latest) page: | ||
|
||
``` | ||
scoop bucket add sst https://github.com/sst/scoop-bucket.git | ||
scoop install sst | ||
``` | ||
|
||
To upgrade to the latest version: | ||
|
||
``` | ||
scoop update sst | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
#### Manually | ||
|
||
Download the pre-compiled binaries from the [releases](https://github.com/sst/ion/releases/latest) page and copy to the desired location. | ||
|
||
## Quick start | ||
|
||
1. Create a new Next.js app. | ||
|
||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
```bash | ||
npx create-next-app@latest | ||
``` | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
2. Initialize SST in the root of your Next.js app. | ||
|
||
## Learn More | ||
```bash | ||
cd my-app | ||
sst create | ||
``` | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
- This creates an `sst.config.ts` in your project root. | ||
- `sst.config.ts` is automatically added to the the `exclude` array in `tsconfig.json` to prevent TypeScript from trying to type-check it when building your app | ||
- You should also add `/.sst` and `/.open-next` to your `.gitignore` file. | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
3. Deploy! Ensure you have AWS credentials setup and run: | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
```bash | ||
sst deploy | ||
``` | ||
|
||
## Deploy with SST | ||
### Custom domains | ||
|
||
You can configure the app with a custom domain hosted on [Route 53](https://aws.amazon.com/route53/). | ||
|
||
```js {3} | ||
new Nextjs("Web", { | ||
domain: "my-app.com", | ||
}); | ||
``` | ||
|
||
You can setup `www.my-app.com` redirect to `my-app.com`. | ||
|
||
```js {3} | ||
new Nextjs("Web", { | ||
domain: { | ||
domainName: "my-app.com", | ||
redirects: ["www.my-app.com"], | ||
}, | ||
}); | ||
``` | ||
|
||
Or you can have `www.my-app.com` serve out the same site without redirecting. | ||
|
||
```js {3} | ||
new Nextjs("Web", { | ||
domain: { | ||
domainName: "my-app.com", | ||
aliases: ["www.my-app.com"], | ||
}, | ||
}); | ||
``` | ||
|
||
Deploy NextJS on AWS with [SST](https://sst.dev) and [Open-Next](https://open-next.js.org/) (It's free NextJS!) | ||
Open-Next is much easier to integrate with an existing AWS back-end, and is a lot cheaper than Vercel. | ||
--- | ||
|
||
Check out our [SST with Next.js deployment documentation](https://docs.sst.dev/start/nextjs) for more details. | ||
Join the `#ion` channel in our [Discord](https://sst.dev/discord) to learn more and contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package global | ||
|
||
import ( | ||
"archive/tar" | ||
"compress/gzip" | ||
"fmt" | ||
"io" | ||
"log/slog" | ||
"net/http" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
"strings" | ||
) | ||
|
||
func Upgrade(version string) error { | ||
var filename string | ||
switch runtime.GOOS { | ||
case "darwin": | ||
filename = "mac-" | ||
case "windows": | ||
filename = "windows-" | ||
default: | ||
filename = "linux-" | ||
} | ||
|
||
switch runtime.GOARCH { | ||
case "amd64": | ||
filename += "x86_64.tar.gz" | ||
case "arm64": | ||
filename += "arm64.tar.gz" | ||
case "386": | ||
filename += "i386.tar.gz" | ||
default: | ||
return fmt.Errorf("unsupported architecture") | ||
} | ||
url := "https://github.com/sst/ion/releases/latest/download/sst-" + filename | ||
if version != "" { | ||
if !strings.HasPrefix(version, "v") { | ||
version = "v" + version | ||
} | ||
url = "https://github.com/sst/ion/releases/download/" + version + "/sst-" + filename | ||
} | ||
slog.Info("downloading", "url", url) | ||
resp, err := http.Get(url) | ||
if err != nil { | ||
return err | ||
} | ||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return fmt.Errorf("unexpected HTTP status when downloading release: %s", resp.Status) | ||
} | ||
|
||
homeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sstBinPath := filepath.Join(homeDir, ".sst", "bin") | ||
if err := os.MkdirAll(sstBinPath, os.ModePerm); err != nil { | ||
return err | ||
} | ||
|
||
// Assuming we have a variable `resp` which is the response from a *http.Request | ||
body, err := gzip.NewReader(resp.Body) | ||
if err != nil { | ||
return err | ||
} | ||
defer body.Close() | ||
|
||
if err := untar(body, sstBinPath); err != nil { | ||
return err | ||
} | ||
|
||
if err := os.Chmod(filepath.Join(sstBinPath, "sst"), 0755); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func untar(reader io.Reader, target string) error { | ||
tarReader := tar.NewReader(reader) | ||
for { | ||
header, err := tarReader.Next() | ||
if err == io.EOF { | ||
break // End of tarball | ||
} | ||
if err != nil { | ||
return err | ||
} | ||
switch header.Typeflag { | ||
case tar.TypeDir: | ||
if err := os.MkdirAll(filepath.Join(target, header.Name), 0755); err != nil { | ||
return err | ||
} | ||
case tar.TypeReg: | ||
outFile, err := os.Create(filepath.Join(target, header.Name)) | ||
if err != nil { | ||
return err | ||
} | ||
if _, err := io.Copy(outFile, tarReader); err != nil { | ||
outFile.Close() | ||
return err | ||
} | ||
outFile.Close() | ||
} | ||
} | ||
return nil | ||
} |