Skip to content

Commit

Permalink
[optimize] upgrade to Next.js 14 & other Upstream packages
Browse files Browse the repository at this point in the history
[refactor] reduce Docker image size
[add] Health Check configuration of Docker services
[add] Entry Badge of GitHub codespaces & GitPod.io
  • Loading branch information
TechQuery committed Nov 26, 2023
1 parent 6f18284 commit 0e1d228
Show file tree
Hide file tree
Showing 8 changed files with 1,077 additions and 965 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Inject Environment variables
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}

- name: Deploy to Vercel
Expand Down
30 changes: 16 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
FROM node:18-slim
# Reference: https://pnpm.io/docker#example-1-build-a-bundle-in-a-docker-container

USER root
FROM node:18-slim AS base
RUN apt-get update && \
apt-get install curl -y --no-install-recommends
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

RUN npm rm yarn -g
RUN npm i pnpm -g
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm i --prod --frozen-lockfile

RUN mkdir /home/node/app
WORKDIR /home/node/app

COPY package.json pnpm-lock.yaml .npmrc /home/node/app/
RUN pnpm i --frozen-lockfile

COPY . /home/node/app
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm i --frozen-lockfile
RUN pnpm build

RUN pnpm prune --prod || true \
pnpm store prune

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
EXPOSE 3000
CMD ["npm", "start"]
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

[React][1] project scaffold based on [TypeScript][2], [Next.js][3], [Bootstrap][4] & [Workbox][5]. And this project bootstrapped with [`create-next-app`][6].

[![NPM Dependency](https://david-dm.org/ideamall/pwa.svg)][7]
[![CI & CD](https://github.com/IdeaMall/PWA/actions/workflows/main.yml/badge.svg)][8]
[![CI & CD](https://github.com/IdeaMall/PWA/actions/workflows/main.yml/badge.svg)][7]

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)][8]
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)][9]

## Technology stack

- Language: [TypeScript v5][2]
- Component engine: [Nextjs v13][3]
- Component suite: [Bootstrap v5][4]
- PWA framework: [Workbox v6][5]
- State management: [MobX v6][9]
- State management: [MobX v6][10]
- CI / CD: GitHub [Actions][11] + [Vercel][12]

## Getting Started
Expand Down Expand Up @@ -61,9 +63,10 @@ pnpm container
[4]: https://getbootstrap.com/
[5]: https://developers.google.com/web/tools/workbox
[6]: https://github.com/vercel/next.js/tree/canary/packages/create-next-app
[7]: https://david-dm.org/ideamall/pwa
[8]: https://github.com/IdeaMall/PWA/actions/workflows/main.yml
[9]: https://github.com/mobxjs/mobx/tree/mobx4and5/docs
[7]: https://github.com/IdeaMall/PWA/actions/workflows/main.yml
[8]: https://codespaces.new/ideaMall/PWA
[9]: https://gitpod.io/?autostart=true#https://github.com/ideaMall/PWA
[10]: https://mobx.js.org/
[11]: https://github.com/features/actions
[12]: https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme
[13]: https://nextjs.org/docs/api-routes/introduction
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ services:
- 3000:3000
networks:
- ideamall
healthcheck:
test: ['CMD-SHELL', 'curl -f http://localhost:3000/ || exit 1']
interval: 3s
retries: 5
start_period: 30s
labels:
- 'autoheal=true'
restart: always
logging:
driver: 'json-file'
options:
max-size: '10m'

autoheal:
image: willfarrell/autoheal:1.2.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: always

caddy:
depends_on:
- pwa
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@
"description": "React project scaffold based on TypeScript, Next.js, Bootstrap & Workbox.",
"private": true,
"dependencies": {
"@authing/guard": "^5.3.0",
"@authing/guard": "^5.3.2",
"@ideamall/data-service": "^1.0.0-alpha.1",
"idea-react": "^1.0.0-rc.30",
"koajax": "^0.9.4",
"koajax": "^0.9.6",
"less": "^4.2.0",
"less-loader": "^11.1.3",
"lodash": "^4.17.21",
"mobx": "^6.10.2",
"mobx-i18n": "^0.4.1",
"mobx-react": "^9.0.1",
"mobx": "~6.10.2",
"mobx-i18n": "^0.4.2",
"mobx-react": "~9.0.2",
"mobx-react-helper": "^0.2.7",
"mobx-restful": "^0.6.12",
"mobx-restful-table": "^1.2.0",
"next": "^13.5.3",
"mobx-restful-table": "^1.2.2",
"next": "^14.0.3",
"next-pwa": "~5.6.0",
"next-ssr-middleware": "^0.5.1",
"next-ssr-middleware": "^0.6.1",
"next-with-less": "^3.0.1",
"react": "^18.2.0",
"react-bootstrap": "^2.9.0",
"react-bootstrap": "^2.9.1",
"react-bootstrap-editor": "^1.0.5",
"react-dom": "^18.2.0",
"web-utility": "^4.1.3"
},
"devDependencies": {
"@octokit/openapi-types": "^19.0.0",
"@types/lodash": "^4.14.199",
"@types/node": "^18.18.3",
"@types/react": "^18.2.24",
"eslint": "^8.50.0",
"eslint-config-next": "^13.5.3",
"@octokit/openapi-types": "^19.0.2",
"@types/lodash": "^4.14.202",
"@types/node": "^18.18.13",
"@types/react": "^18.2.38",
"eslint": "^8.54.0",
"eslint-config-next": "^14.0.3",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"lint-staged": "^15.1.0",
"prettier": "^3.1.0",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
"typescript": "~5.3.2"
},
"prettier": {
"singleQuote": true,
Expand Down
8 changes: 2 additions & 6 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ export default function Document() {

<link
rel="stylesheet"
href="https://unpkg.com/[email protected].0-alpha1/dist/css/bootstrap.min.css"
href="https://unpkg.com/[email protected].2/dist/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/index.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/font/bootstrap-icons.css"
href="https://unpkg.com/[email protected]/font/bootstrap-icons.css"
/>
</Head>

Expand Down
Loading

1 comment on commit 0e1d228

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for idea-mall ready!

✅ Preview
https://idea-mall-b2ildnmp4-techquery.vercel.app

Built with commit 0e1d228.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.