Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit 654a1e0

Browse files
committed
docs: astro container quick start
1 parent a2da71c commit 654a1e0

File tree

20 files changed

+667
-11
lines changed

20 files changed

+667
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
node_modules
3+
dist
4+
5+
6+
# sst
7+
.sst
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# build output
2+
dist/
3+
4+
# generated types
5+
.astro/
6+
7+
# dependencies
8+
node_modules/
9+
10+
# logs
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store
22+
23+
# jetbrains setting folder
24+
.idea/
25+
26+
# sst
27+
.sst
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"recommendations": ["astro-build.astro-vscode"],
3+
"unwantedRecommendations": []
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"command": "./node_modules/.bin/astro dev",
6+
"name": "Development server",
7+
"request": "launch",
8+
"type": "node-terminal"
9+
}
10+
]
11+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# From https://docs.astro.build/en/recipes/docker/
2+
3+
FROM node:lts AS base
4+
WORKDIR /app
5+
6+
# By copying only the package.json and package-lock.json here, we ensure that the following `-deps` steps are independent of the source code.
7+
# Therefore, the `-deps` steps will be skipped if only the source code changes.
8+
COPY package.json package-lock.json ./
9+
10+
FROM base AS prod-deps
11+
RUN npm install --omit=dev
12+
13+
FROM base AS build-deps
14+
RUN npm install
15+
16+
FROM build-deps AS build
17+
COPY . .
18+
RUN npm run build
19+
20+
FROM base AS runtime
21+
COPY --from=prod-deps /app/node_modules ./node_modules
22+
COPY --from=build /app/dist ./dist
23+
24+
ENV HOST=0.0.0.0
25+
ENV PORT=4321
26+
EXPOSE 4321
27+
CMD node ./dist/server/entry.mjs
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Astro Starter Kit: Basics
2+
3+
```sh
4+
npm create astro@latest -- --template basics
5+
```
6+
7+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
8+
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics)
9+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json)
10+
11+
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
12+
13+
![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554)
14+
15+
## 🚀 Project Structure
16+
17+
Inside of your Astro project, you'll see the following folders and files:
18+
19+
```text
20+
/
21+
├── public/
22+
│ └── favicon.svg
23+
├── src/
24+
│ ├── components/
25+
│ │ └── Card.astro
26+
│ ├── layouts/
27+
│ │ └── Layout.astro
28+
│ └── pages/
29+
│ └── index.astro
30+
└── package.json
31+
```
32+
33+
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
34+
35+
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
36+
37+
Any static assets, like images, can be placed in the `public/` directory.
38+
39+
## 🧞 Commands
40+
41+
All commands are run from the root of the project, from a terminal:
42+
43+
| Command | Action |
44+
| :------------------------ | :----------------------------------------------- |
45+
| `npm install` | Installs dependencies |
46+
| `npm run dev` | Starts local dev server at `localhost:4321` |
47+
| `npm run build` | Build your production site to `./dist/` |
48+
| `npm run preview` | Preview your build locally, before deploying |
49+
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
50+
| `npm run astro -- --help` | Get help using the Astro CLI |
51+
52+
## 👀 Want to learn more?
53+
54+
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @ts-check
2+
import { defineConfig } from 'astro/config';
3+
4+
import node from '@astrojs/node';
5+
6+
// https://astro.build/config
7+
export default defineConfig({
8+
output: 'server',
9+
10+
adapter: node({
11+
mode: 'standalone'
12+
})
13+
});
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "aws-astro-container",
3+
"type": "module",
4+
"version": "0.0.1",
5+
"scripts": {
6+
"astro": "astro",
7+
"build": "astro check && astro build",
8+
"dev": "astro dev",
9+
"preview": "astro preview",
10+
"start": "astro dev"
11+
},
12+
"dependencies": {
13+
"@astrojs/check": "^0.9.4",
14+
"@astrojs/node": "^8.3.4",
15+
"astro": "^4.16.3",
16+
"astro-sst": "2.43.5",
17+
"ioredis": "^5.4.1",
18+
"sst": "latest",
19+
"typescript": "^5.6.3"
20+
}
21+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
interface Props {
3+
title: string;
4+
body: string;
5+
href: string;
6+
}
7+
8+
const { href, title, body } = Astro.props;
9+
---
10+
11+
<li class="link-card">
12+
<a href={href}>
13+
<h2>
14+
{title}
15+
<span>&rarr;</span>
16+
</h2>
17+
<p>
18+
{body}
19+
</p>
20+
</a>
21+
</li>
22+
<style>
23+
.link-card {
24+
list-style: none;
25+
display: flex;
26+
padding: 1px;
27+
background-color: #23262d;
28+
background-image: none;
29+
background-size: 400%;
30+
border-radius: 7px;
31+
background-position: 100%;
32+
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
33+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
34+
}
35+
.link-card > a {
36+
width: 100%;
37+
text-decoration: none;
38+
line-height: 1.4;
39+
padding: calc(1.5rem - 1px);
40+
border-radius: 8px;
41+
color: white;
42+
background-color: #23262d;
43+
opacity: 0.8;
44+
}
45+
h2 {
46+
margin: 0;
47+
font-size: 1.25rem;
48+
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
49+
}
50+
p {
51+
margin-top: 0.5rem;
52+
margin-bottom: 0;
53+
}
54+
.link-card:is(:hover, :focus-within) {
55+
background-position: 0;
56+
background-image: var(--accent-gradient);
57+
}
58+
.link-card:is(:hover, :focus-within) h2 {
59+
color: rgb(var(--accent-light));
60+
}
61+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="../.astro/types.d.ts" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
interface Props {
3+
title: string;
4+
}
5+
6+
const { title } = Astro.props;
7+
---
8+
9+
<!doctype html>
10+
<html lang="en">
11+
<head>
12+
<meta charset="UTF-8" />
13+
<meta name="description" content="Astro description" />
14+
<meta name="viewport" content="width=device-width" />
15+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
16+
<meta name="generator" content={Astro.generator} />
17+
<title>{title}</title>
18+
</head>
19+
<body>
20+
<slot />
21+
</body>
22+
</html>
23+
<style is:global>
24+
:root {
25+
--accent: 136, 58, 234;
26+
--accent-light: 224, 204, 250;
27+
--accent-dark: 49, 10, 101;
28+
--accent-gradient: linear-gradient(
29+
45deg,
30+
rgb(var(--accent)),
31+
rgb(var(--accent-light)) 30%,
32+
white 60%
33+
);
34+
}
35+
html {
36+
font-family: system-ui, sans-serif;
37+
background: #13151a;
38+
}
39+
code {
40+
font-family:
41+
Menlo,
42+
Monaco,
43+
Lucida Console,
44+
Liberation Mono,
45+
DejaVu Sans Mono,
46+
Bitstream Vera Sans Mono,
47+
Courier New,
48+
monospace;
49+
}
50+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
import { Resource } from "sst";
3+
import { Cluster } from "ioredis";
4+
import Layout from '../layouts/Layout.astro';
5+
6+
const redis = new Cluster(
7+
[{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }],
8+
{
9+
dnsLookup: (address, callback) => callback(null, address),
10+
redisOptions: {
11+
tls: {},
12+
username: Resource.MyRedis.username,
13+
password: Resource.MyRedis.password,
14+
},
15+
}
16+
);
17+
18+
const counter = await redis.incr("counter");
19+
---
20+
21+
<Layout title="Welcome to Astro.">
22+
<main>
23+
<h1>Hit counter: {counter}</h1>
24+
</main>
25+
</Layout>
26+
27+
<style>
28+
main {
29+
margin: auto;
30+
padding: 1rem;
31+
width: 800px;
32+
max-width: calc(100% - 2rem);
33+
color: white;
34+
font-size: 20px;
35+
line-height: 1.6;
36+
}
37+
h1 {
38+
font-size: 4rem;
39+
font-weight: 700;
40+
line-height: 1;
41+
text-align: center;
42+
margin-bottom: 1em;
43+
}
44+
</style>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* This file is auto-generated by SST. Do not edit. */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
import "sst"
5+
export {}
6+
declare module "sst" {
7+
export interface Resource {
8+
"MyRedis": {
9+
"host": string
10+
"password": string
11+
"port": number
12+
"type": "sst.aws.Redis"
13+
"username": string
14+
}
15+
"MyService": {
16+
"service": string
17+
"type": "sst.aws.Service"
18+
"url": string
19+
}
20+
"MyVpc": {
21+
"bastion": string
22+
"type": "sst.aws.Vpc"
23+
}
24+
}
25+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference path="./.sst/platform/config.d.ts" />
2+
3+
export default $config({
4+
app(input) {
5+
return {
6+
name: "aws-astro-container",
7+
removal: input?.stage === "production" ? "retain" : "remove",
8+
home: "aws",
9+
};
10+
},
11+
async run() {
12+
const vpc = new sst.aws.Vpc("MyVpc", { bastion: true });
13+
const redis = new sst.aws.Redis("MyRedis", { vpc });
14+
const cluster = new sst.aws.Cluster("MyCluster", { vpc });
15+
16+
cluster.addService("MyService", {
17+
link: [redis],
18+
public: {
19+
ports: [{ listen: "80/http", forward: "4321/http" }],
20+
},
21+
dev: {
22+
command: "npm run dev",
23+
},
24+
});
25+
}
26+
});

0 commit comments

Comments
 (0)