Skip to content

Commit

Permalink
updates: added an article about EC2 pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
janakhpon committed Dec 29, 2021
1 parent 80e4294 commit b656c28
Show file tree
Hide file tree
Showing 38 changed files with 594 additions and 2,898 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ A collection of mono repos from my personal blog posts.
[React Query](https://janakhpon.gitlab.io/posts/react-query)

[Next Translate](https://janakhpon.gitlab.io/posts/next-translate)

[Postgresql on AWS](https://janakhpon.gitlab.io/posts/setup-postgresql-aws-rds)

[Passwordless ssh login](https://janakhpon.gitlab.io/posts/setup-passwordless-ssh)

[Posgresql on VPS](https://janakhpon.gitlab.io/posts/setup-postgresql-vps)

[Basic CICD on EC2](https://janakhpon.gitlab.io/posts/setup-basic-cicd-ec2)
3 changes: 3 additions & 0 deletions next-seo-pwa-cicd/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
34 changes: 34 additions & 0 deletions next-seo-pwa-cicd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
35 changes: 35 additions & 0 deletions next-seo-pwa-cicd/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
image: node:14

stages:
- build
- deploy

build_develop:
stage: build
artifacts:
paths:
- build/
expire_in: 1 week
cache:
paths:
- node_modules/
only:
- develop
before_script:
- npm install
script:
- npm run build

deploy_develop:
stage: deploy
only:
- develop
before_script:
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- touch ~/.ssh/config
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- ssh-add <(echo "$SSH_PRIVATE_KEY")
script:
- scp -P22 -r ./* "$INSTANCE_ADDR":/home/ubuntu/develop/web/
- ssh -o StrictHostKeyChecking=no "$INSTANCE_ADDR" "cd develop/web && pwd && bash scripts/install_and_reload.sh"
34 changes: 34 additions & 0 deletions next-seo-pwa-cicd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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:

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [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.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
6 changes: 6 additions & 0 deletions next-seo-pwa-cicd/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
12 changes: 12 additions & 0 deletions next-seo-pwa-cicd/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const withPWA = require('next-pwa')

module.exports = withPWA({
pwa: {
dest: 'public',
// disable: process.env.NODE_ENV === 'development',
// register: true,
// scope: '/app',
// sw: 'service-worker.js',
//...
}
})

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

24 changes: 24 additions & 0 deletions next-seo-pwa-cicd/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "next-seo-pwa-cicd",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build:local": "next build",
"build": "next build && next export -o build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "11.1.0",
"next-pwa": "^5.3.1",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/react": "17.0.19",
"eslint": "7.32.0",
"eslint-config-next": "11.1.0",
"typescript": "4.3.5"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added next-seo-pwa-cicd/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions next-seo-pwa-cicd/public/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
1 change: 1 addition & 0 deletions next-seo-pwa-cicd/public/fallback-jrNBN8QkKKVAMZn-UM8mO.js

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

Binary file added next-seo-pwa-cicd/public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added next-seo-pwa-cicd/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added next-seo-pwa-cicd/public/favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions next-seo-pwa-cicd/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "PWA",
"short_name": "PWA",
"display": "standalone",
"orientation": "portrait",
"theme_color": "#FFFFFF",
"background_color": "#FFFFFF",
"start_url": "/",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
Binary file added next-seo-pwa-cicd/public/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions next-seo-pwa-cicd/public/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions next-seo-pwa-cicd/public/sw.js

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

1 change: 1 addition & 0 deletions next-seo-pwa-cicd/public/workbox-21b21c9a.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions next-seo-pwa-cicd/scripts/install_and_reload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/ubuntu/.nvm/versions/node/v14.17.2/bin/pm2 stop develop_web && /home/ubuntu/.nvm/versions/node/v14.17.2/bin/pm2 delete develop_web && /home/ubuntu/.nvm/versions/node/v14.17.2/bin/pm2 serve build 3000 --name develop_web
19 changes: 19 additions & 0 deletions next-seo-pwa-cicd/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import '../../styles/globals.css'
import type { AppProps } from 'next/app'
import Head from "next/head";

function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title>PWA 🔥 </title>
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no, viewport-fit=cover"
/>
</Head>
<Component {...pageProps} />
</>
)
}
export default MyApp
101 changes: 101 additions & 0 deletions next-seo-pwa-cicd/src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import Document, { Html, Head, Main, NextScript } from "next/document";
import React from "react";

const url = `http://localhost:3000/`;
const description = `HaHa | HeHe`
const name = "HaHa"
const social_image = "mstile-150x150.png"

export default class extends Document {
static async getInitialProps(ctx: any) {
return await Document.getInitialProps(ctx);
}

render() {
return (
<Html lang="en" dir="ltr">
<Head>

{/* HERE I AM 👇*/}
<meta name='application-name' content='PWA App' />
<meta name='apple-mobile-web-app-capable' content='yes' />
<meta name='apple-mobile-web-app-status-bar-style' content='default' />
<meta name='apple-mobile-web-app-title' content='PWA App' />
<meta name='description' content='Best PWA App in the world' />
<meta name='format-detection' content='telephone=no' />
<meta name='mobile-web-app-capable' content='yes' />
<meta name='msapplication-config' content='/icons/browserconfig.xml' />
<meta name='msapplication-TileColor' content='#2B5797' />
<meta name='msapplication-tap-highlight' content='no' />
<meta name='theme-color' content='#000000' />


<meta
name="keywords"
content="Hello, hola, blah blah"
/>
<meta name="author" content="Ja Nakh Pon" />
<meta name="robots" content="index,follow" />
<meta name="googlebot" content="index,follow" />
<meta name="description" content={description} />
<meta name="theme-color" content="#006ABC" />

{/* openGraph */}
<meta property="og:title" content={name} />
<meta
property="og:description"
content={description}
/>
<meta property="og:type" content={"website"} />
<meta property="og:url" content={url} />
<meta property="og:locale" content="en_IE" />
<meta property="og:site_name" content={name} />
<meta property="og:image" content={social_image} />

{/* Twitter */}
<meta name="twitter:site" content={`@ja_nakh`} />
<meta name="twitter:creator" content={`@ja_nakh`} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={name} />
<meta
name="twitter:description"
content={description}
/>
<meta name="twitter:image" content={social_image} />


<link rel="canonical" href={url} />
<link rel="icon" href="/favicon.ico" />
<link
rel="apple-touch-icon"
sizes="180x180"
href="/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/favicon-16x16.png"
/>

{/* AND HERE 👇*/}
<link rel="manifest" href="/manifest.json" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#006ABC" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
11 changes: 11 additions & 0 deletions next-seo-pwa-cicd/src/pages/_offline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Head from "next/head";

const Offline = () => (
<>
<Head>
<title>PWA</title>
</Head>
<h1>Oops! you are offline!</h1>
</>
);
export default Offline;
Loading

0 comments on commit b656c28

Please sign in to comment.