Skip to content

Commit

Permalink
Deploy via SST to AWS (#701)
Browse files Browse the repository at this point in the history
* add SST config

* Do a deploy to AWS with SST
  • Loading branch information
petrvecera authored Feb 9, 2025
1 parent 81f758b commit f2ffcb6
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
environment: ${{ env.EDGIO_ENV }}
ignore_empty: true
ignore_missing: true
- name: "Deploy to AWS"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
npx sst deploy --stage staging
- name: Deploy to Netlify hosting
env:
NETLIFY_AUTH_TOKEN: ${{secrets.NETLIFY_AUTH_TOKEN}}
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,9 @@ next.config.original.js

# Local Netlify folder
.netlify

# sst
.sst

# open-next
.open-next
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
"npm": "please-use-yarn"
},
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"next:dev": "next dev",
"next:build": "next build",
"build:analyze": "ANALYZE=true yarn build",
"test": "TZ=UTC yarn jest",
"test:windows": "yarn jest",
"clean": "rm -fr .next && rm -fr node_modules",
"dev": "next dev",
"fix": "prettier --loglevel warn --write .",
"fix:prettier": "prettier --log-level warn --write .",
"lint": "next lint",
"lint:eslint": "eslint **/*.{ts,tsx,js}",
"lint:prettier": "prettier --check .",
"fix": "prettier --loglevel warn --write .",
"fix:prettier": "prettier --log-level warn --write .",
"clean": "rm -fr .next && rm -fr node_modules",
"next:build": "next build",
"next:dev": "next dev",
"prepare": "husky",
"sitemap": "npx --yes ts-node --compiler-options \"{\\\"module\\\":\\\"commonjs\\\"}\" scripts/unit-paths.ts > unit-paths.txt && next-sitemap --config next-sitemap.config.js"
"sitemap": "npx --yes ts-node --compiler-options \"{\\\"module\\\":\\\"commonjs\\\"}\" scripts/unit-paths.ts > unit-paths.txt && next-sitemap --config next-sitemap.config.js",
"start": "next start",
"test": "TZ=UTC yarn jest",
"test:windows": "yarn jest"
},
"lint-staged": {
"*.{js,ts,jsx,tsx,yml}": [
Expand Down Expand Up @@ -75,6 +75,7 @@
"react": "18.3.1",
"react-chartjs-2": "5.2.0",
"react-dom": "18.3.1",
"sst": "3.8.2",
"timeago.js": "4.0.2"
},
"devDependencies": {
Expand Down
44 changes: 44 additions & 0 deletions sst.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./.sst/platform/config.d.ts" />
export default $config({
app(input) {
return {
name: "coh3-stats",
removal: input?.stage === "production" ? "retain" : "remove",
protect: ["production"].includes(input?.stage),
home: "aws",
providers: {
cloudflare: "5.49.0",
aws: {
region: "us-east-2",
},
},
};
},
async run() {
new sst.aws.Nextjs("coh3-stats", {
domain: {
name:
$app.stage === "staging"
? "dev.coh3stats.com"
: $app.stage === "production"
? "coh3stats.com"
: undefined,
dns: sst.cloudflare.dns({
proxy: true,
override: true,
}),
},
transform: {
cdn: (args) => {
args.transform = {
distribution: (distArgs) => {
// Only US and EU
distArgs.priceClass = "PriceClass_100";
},
};
},
},
});
},
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"downlevelIteration": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": ["node_modules","sst.config.ts"]
}
75 changes: 75 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5370,6 +5370,11 @@ avvio@^8.3.0:
"@fastify/error" "^3.3.0"
fastq "^1.17.1"

aws4fetch@^1.0.18:
version "1.0.20"
resolved "https://registry.yarnpkg.com/aws4fetch/-/aws4fetch-1.0.20.tgz#090d6c65e32c6df645dd5e5acf04cc56da575cbe"
integrity sha512-/djoAN709iY65ETD6LKCtyyEI04XIBP5xVvfmNxsEP0uJB5tyaGBztSryRr4HqMStr9R06PisQE7m9zDTXKu6g==

axe-core@=4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.7.0.tgz#34ba5a48a8b564f67e103f0aa5768d76e15bbbbf"
Expand Down Expand Up @@ -10435,6 +10440,16 @@ jiti@^2.1.2:
resolved "https://registry.yarnpkg.com/jiti/-/jiti-2.4.1.tgz#4de9766ccbfa941d9b6390d2b159a4b295a52e6b"
integrity sha512-yPBThwecp1wS9DmoA4x4KR2h3QoslacnDR8ypuFM962kI4/456Iy1oHx2RAgh4jfZNdn0bctsdadceiBUgpU1g==

[email protected]:
version "5.2.3"
resolved "https://registry.yarnpkg.com/jose/-/jose-5.2.3.tgz#071c87f9fe720cff741a403c8080b69bfe13164a"
integrity sha512-KUXdbctm1uHVL8BYhnyHkgp3zDX5KW8ZhAKVFEfUbU2P8Alpzjb+48hHvjOdQIyPshoblhzsuqOwEEAbtHVirA==

jose@^4.15.4:
version "4.15.9"
resolved "https://registry.yarnpkg.com/jose/-/jose-4.15.9.tgz#9b68eda29e9a0614c042fa29387196c7dd800100"
integrity sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==

js-string-escape@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef"
Expand Down Expand Up @@ -11868,6 +11883,11 @@ object-assign@^4.1.1:
resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"
integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==

object-hash@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.2.0.tgz#5ad518581eefc443bd763472b8ff2e9c2c0d54a5"
integrity sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==

object-inspect@^1.12.2, object-inspect@^1.9.0:
version "1.12.2"
resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz"
Expand Down Expand Up @@ -11981,6 +12001,11 @@ ohash@^1.1.4:
resolved "https://registry.yarnpkg.com/ohash/-/ohash-1.1.4.tgz#ae8d83014ab81157d2c285abf7792e2995fadd72"
integrity sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==

oidc-token-hash@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/oidc-token-hash/-/oidc-token-hash-5.0.3.tgz#9a229f0a1ce9d4fc89bcaee5478c97a889e7b7b6"
integrity sha512-IF4PcGgzAr6XXSff26Sk/+P4KZFJVuHAJZj3wgO3vX2bMdNVp/QXTP3P7CEm9V1IdG8lDLY3HhiqpsE/nOwpPw==

omit.js@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/omit.js/-/omit.js-2.0.2.tgz#dd9b8436fab947a5f3ff214cb2538631e313ec2f"
Expand Down Expand Up @@ -12075,6 +12100,16 @@ opener@^1.5.2:
resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598"
integrity sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==

[email protected]:
version "5.6.4"
resolved "https://registry.yarnpkg.com/openid-client/-/openid-client-5.6.4.tgz#b2c25e6d5338ba3ce00e04341bb286798a196177"
integrity sha512-T1h3B10BRPKfcObdBklX639tVz+xh34O7GjofqrqiAQdm7eHsQ00ih18x6wuJ/E6FxdtS2u3FmUGPDeEcMwzNA==
dependencies:
jose "^4.15.4"
lru-cache "^6.0.0"
object-hash "^2.2.0"
oidc-token-hash "^5.0.3"

optionator@^0.8.1:
version "0.8.3"
resolved "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz"
Expand Down Expand Up @@ -13910,6 +13945,46 @@ sprintf-js@~1.0.2:
resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz"
integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==

[email protected]:
version "3.8.2"
resolved "https://registry.yarnpkg.com/sst-darwin-arm64/-/sst-darwin-arm64-3.8.2.tgz#cff9467cc2c362d16423d40eb37fab2917d9fef7"
integrity sha512-N0nZJAkrNUpRmRkNz3T5QA7s6QPi9hgAJJorPv0VQwhGtoxnsPU8RgVqklQKVHBgH3f4FThESZGMKPKt2JcvcA==

[email protected]:
version "3.8.2"
resolved "https://registry.yarnpkg.com/sst-darwin-x64/-/sst-darwin-x64-3.8.2.tgz#7c31975fd4ddf61bf0c59943efc3e1f45c1d4414"
integrity sha512-RDf/kVYNE+vXNiNBK6v3LHz1YEa3Ka8/G2T52mI4qQh40ZBbEapIR7x6dZqV0kLQQTs4t/XxSkf9wH7pft1tEA==

[email protected]:
version "3.8.2"
resolved "https://registry.yarnpkg.com/sst-linux-arm64/-/sst-linux-arm64-3.8.2.tgz#23a51d7e34ba3df8d722e81f5fe60ef7f73d2525"
integrity sha512-CGS81oW+96HJ5ZkjjHCNCk5YLwPDbqQKPnyC/APFzHMLC+gSPMVU0Ig6gKBvJ7mIzEwSEIxPoGnZkjZjxLlG4w==

[email protected]:
version "3.8.2"
resolved "https://registry.yarnpkg.com/sst-linux-x64/-/sst-linux-x64-3.8.2.tgz#cde6941fdda0c24fb384f71b830ae36ee41e644e"
integrity sha512-8K5giZiSEnNTBnlYBMf/IEM0ywNuakKzHjLQRh0VCWfEcyWgL1uxeOUtDIh6KyNW6Ww7/uEYtySqax3KkZIKiA==

[email protected]:
version "3.8.2"
resolved "https://registry.yarnpkg.com/sst-linux-x86/-/sst-linux-x86-3.8.2.tgz#d3c9c336c9cbb9a9be07cd9a8252743644ce19e1"
integrity sha512-uBFhhqr2sAq51YKkFN4v8mYIKsiKOJCyB2afoue+vF6QEwlyubnbftWwv0ISfHKUZ1DbxTnO78dAMYA4hAuVCA==

[email protected]:
version "3.8.2"
resolved "https://registry.yarnpkg.com/sst/-/sst-3.8.2.tgz#0e0a3a0fecbe4405c41ca8ff6b50a85ad0f434b0"
integrity sha512-CoFlEiX8cdqB/sgn4ZN+BnJaPlOUk2eGzMwTbPFkBn3hHAQMNdo1UXdo+DwbfE0en9K4Ol0j/AIO6TBTRfUIow==
dependencies:
aws4fetch "^1.0.18"
jose "5.2.3"
openid-client "5.6.4"
optionalDependencies:
sst-darwin-arm64 "3.8.2"
sst-darwin-x64 "3.8.2"
sst-linux-arm64 "3.8.2"
sst-linux-x64 "3.8.2"
sst-linux-x86 "3.8.2"

stack-generator@^2.0.3:
version "2.0.10"
resolved "https://registry.yarnpkg.com/stack-generator/-/stack-generator-2.0.10.tgz#8ae171e985ed62287d4f1ed55a1633b3fb53bb4d"
Expand Down

0 comments on commit f2ffcb6

Please sign in to comment.