diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d460fd1..8752b0e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,67 +1,67 @@ -name: CI/CD - -on: - push: - branches: [ "main" ] - workflow_dispatch: - -jobs: - build_docker: - name: Build Docker - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v4 - with: - context: . - push: true - platforms: linux/amd64 - tags: | - ${{ vars.DOCKERHUB_USERNAME }}/${{ vars.IMAGE_NAME }}:latest - cache-from: type=gha - cache-to: type=gha,mode=max - - build_docker_acr: - name: Build Docker ACR - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Login to ACR - uses: aliyun/acr-login@v1 - with: - login-server: https://${{ vars.REGISTRY_ADDRESS }} - username: "${{ vars.REGISTRY_USERNAME }}" - password: "${{ secrets.REGISTRY_PASSWORD }}" - - name: Build and push image - run: | - docker build -t ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_NAMESPACE }}/${{ vars.IMAGE_NAME }}:latest . - docker push ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_NAMESPACE }}/${{ vars.IMAGE_NAME }}:latest - - deploy: - name: Deploy - needs: [build_docker, build_docker_acr] - runs-on: ubuntu-latest - steps: - - name: SSH To Host - uses: appleboy/ssh-action@v1.0.1 - with: - host: ${{ secrets.SSH_HOST }} - username: ${{ secrets.SSH_USER }} - key: ${{ secrets.SSH_KEY }} - port: ${{ secrets.SSH_PORT }} - script: | - cd ${{ secrets.PROJECT_PATH }} - sudo bash ./deploy.sh +name: CI/CD + +on: + push: + branches: [ "main" ] + workflow_dispatch: + +jobs: + build_docker: + name: Build Docker + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v4 + with: + context: . + push: true + platforms: linux/amd64 + tags: | + ${{ vars.DOCKERHUB_USERNAME }}/${{ vars.IMAGE_NAME }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + build_docker_acr: + name: Build Docker ACR + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Login to ACR + uses: aliyun/acr-login@v1 + with: + login-server: https://${{ vars.REGISTRY_ADDRESS }} + username: "${{ vars.REGISTRY_USERNAME }}" + password: "${{ secrets.REGISTRY_PASSWORD }}" + - name: Build and push image + run: | + docker build -t ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_NAMESPACE }}/${{ vars.IMAGE_NAME }}:latest . + docker push ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_NAMESPACE }}/${{ vars.IMAGE_NAME }}:latest + + deploy: + name: Deploy + needs: [build_docker, build_docker_acr] + runs-on: ubuntu-latest + steps: + - name: SSH To Host + uses: appleboy/ssh-action@v1.0.1 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_KEY }} + port: ${{ secrets.SSH_PORT }} + script: | + cd ${{ secrets.PROJECT_PATH }} + sudo bash ./deploy.sh diff --git a/.github/workflows/dry-build.yml b/.github/workflows/dry-build.yml index 196d860..fcbef05 100644 --- a/.github/workflows/dry-build.yml +++ b/.github/workflows/dry-build.yml @@ -1,16 +1,16 @@ -name: Dry Build - -on: - pull_request: - -jobs: - dry_build: - name: Dry Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v4 - - run: pnpm i --frozen-lockfile +name: Dry Build + +on: + pull_request: + +jobs: + dry_build: + name: Dry Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v4 + - run: pnpm i --frozen-lockfile - run: pnpm run build \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 0ce7a27..5427e44 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,20 +1,20 @@ -{ - "MicroPython.executeButton": [ - { - "text": "▶", - "tooltip": "运行", - "alignment": "left", - "command": "extension.executeFile", - "priority": 3.5 - } - ], - "MicroPython.syncButton": [ - { - "text": "$(sync)", - "tooltip": "同步", - "alignment": "left", - "command": "extension.execute", - "priority": 4 - } - ] +{ + "MicroPython.executeButton": [ + { + "text": "▶", + "tooltip": "运行", + "alignment": "left", + "command": "extension.executeFile", + "priority": 3.5 + } + ], + "MicroPython.syncButton": [ + { + "text": "$(sync)", + "tooltip": "同步", + "alignment": "left", + "command": "extension.execute", + "priority": 4 + } + ] } \ No newline at end of file diff --git a/LICENSE b/LICENSE index 3032496..6522b8b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2024 Vastsea - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2024 Vastsea + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dockerfile b/dockerfile index 7ae3e9e..c7e9cf4 100644 --- a/dockerfile +++ b/dockerfile @@ -1,46 +1,46 @@ -FROM node:18-alpine AS base - -FROM base AS deps -RUN apk add --no-cache libc6-compat -WORKDIR /app - -COPY package.json pnpm-lock.yaml ./ -RUN \ - if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ - fi - -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . - -RUN \ - if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ - else echo "Lockfile not found." && exit 1; \ - fi - -FROM base AS runner -WORKDIR /app - -ENV NODE_ENV=production - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder /app/public ./public - -RUN mkdir .next -RUN chown nextjs:nodejs .next - -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static - -USER nextjs - -EXPOSE 3000 - -ENV PORT=3000 - -ENV HOSTNAME="0.0.0.0" +FROM node:18-alpine AS base + +FROM base AS deps +RUN apk add --no-cache libc6-compat +WORKDIR /app + +COPY package.json pnpm-lock.yaml ./ +RUN \ + if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +RUN \ + if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ + else echo "Lockfile not found." && exit 1; \ + fi + +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +RUN mkdir .next +RUN chown nextjs:nodejs .next + +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 + +ENV HOSTNAME="0.0.0.0" CMD ["node", "server.js"] \ No newline at end of file diff --git a/messages/en-us.json b/messages/en-us.json index 0634628..631f45c 100644 --- a/messages/en-us.json +++ b/messages/en-us.json @@ -1,6 +1,6 @@ -{ - "Metadata": { - "title":"Home | TeamVastsea", - "description": "" - } +{ + "Metadata": { + "title":"Home | TeamVastsea", + "description": "" + } } \ No newline at end of file diff --git a/messages/zh-cn.json b/messages/zh-cn.json index 30e9010..1c7076a 100644 --- a/messages/zh-cn.json +++ b/messages/zh-cn.json @@ -1,6 +1,6 @@ -{ - "Metadata": { - "title":"首页 | 瀚海工艺", - "description": "" - } +{ + "Metadata": { + "title":"首页 | 瀚海工艺", + "description": "" + } } \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index 1fe42bc..ae9ead7 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,10 +1,10 @@ -import createNextIntlPlugin from 'next-intl/plugin'; - -const withNextIntl = createNextIntlPlugin(); -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = { - output: "standalone", -}; - +import createNextIntlPlugin from 'next-intl/plugin'; + +const withNextIntl = createNextIntlPlugin(); +import type { NextConfig } from "next"; + +const nextConfig: NextConfig = { + output: "standalone", +}; + export default withNextIntl(nextConfig); \ No newline at end of file diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 8fd5904..3d3147f 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -1,3 +1,9 @@ -export default function NavBar(){ - return <>测试; +import styles from "@/styles/navbar.module.css"; + +export default function NavBar(){ + return ( + + ); } \ No newline at end of file diff --git a/src/i18n/request.ts b/src/i18n/request.ts index ea9d961..994df02 100644 --- a/src/i18n/request.ts +++ b/src/i18n/request.ts @@ -1,13 +1,13 @@ -import {getRequestConfig} from 'next-intl/server'; -import {routing} from './routing'; - -export default getRequestConfig(async ({requestLocale}) => { - let locale = await requestLocale; - if (!locale || !routing.locales.includes(locale as "zh-cn"|"en-us")) { - locale = routing.defaultLocale; - } - return { - locale, - messages: (await import(`@/messages/${locale}.json`)).default - }; +import {getRequestConfig} from 'next-intl/server'; +import {routing} from './routing'; + +export default getRequestConfig(async ({requestLocale}) => { + let locale = await requestLocale; + if (!locale || !routing.locales.includes(locale as "zh-cn"|"en-us")) { + locale = routing.defaultLocale; + } + return { + locale, + messages: (await import(`@/messages/${locale}.json`)).default + }; }); \ No newline at end of file diff --git a/src/i18n/routing.ts b/src/i18n/routing.ts index 34caa74..d94f6e1 100644 --- a/src/i18n/routing.ts +++ b/src/i18n/routing.ts @@ -1,9 +1,9 @@ -import { defineRouting } from 'next-intl/routing'; -import { createNavigation } from 'next-intl/navigation'; - -export const routing = defineRouting({ - locales: ['zh-cn', 'en-us'], - defaultLocale: 'zh-cn' -}); - +import { defineRouting } from 'next-intl/routing'; +import { createNavigation } from 'next-intl/navigation'; + +export const routing = defineRouting({ + locales: ['zh-cn', 'en-us'], + defaultLocale: 'zh-cn' +}); + export const {Link, redirect, usePathname, useRouter} = createNavigation(routing); \ No newline at end of file diff --git a/src/middleware.ts b/src/middleware.ts index c3eaf99..47616c4 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,8 +1,8 @@ -import createMiddleware from 'next-intl/middleware'; -import { routing } from './i18n/routing'; - -export default createMiddleware(routing); - -export const config = { - matcher: ['/', '/(en-us|zh-cn)/:path*'] +import createMiddleware from 'next-intl/middleware'; +import { routing } from './i18n/routing'; + +export default createMiddleware(routing); + +export const config = { + matcher: ['/', '/(en-us|zh-cn)/:path*'] }; \ No newline at end of file diff --git a/src/styles/global.scss b/src/styles/global.scss index 30031bc..771f684 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -1,4 +1,4 @@ -:root{ - --global-font: "Noto Sans SC", sans-serif,system-ui,"PingFang SC","Microsoft Yahei"; - --mantine-font-family: var(--global-font); +:root{ + --global-font: "Noto Sans SC", sans-serif,system-ui,"PingFang SC","Microsoft Yahei"; + --mantine-font-family: var(--global-font); } \ No newline at end of file diff --git a/src/styles/navbar.module.scss b/src/styles/navbar.module.scss new file mode 100644 index 0000000..4d12889 --- /dev/null +++ b/src/styles/navbar.module.scss @@ -0,0 +1,7 @@ +#navbar{ + position: sticky; + top: 0; + left: 0; + width: 100%; + height: var(); +} \ No newline at end of file