From 277d3cc46d6fa9ab1e36877ab7481af0519b07a9 Mon Sep 17 00:00:00 2001 From: chenshaowen <“mail@chenshaowen.com”> Date: Tue, 18 Apr 2023 17:56:32 +0800 Subject: [PATCH] feature: add build container image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenshaowen <“mail@chenshaowen.com”> --- .dockerignore | 2 + .github/workflows/build.yaml | 40 +++++++++++ .gitignore | 131 +++++++++++++++++++++++++++++++++++ docker/Dockerfile | 10 +++ docker/default.conf | 13 ++++ next.config.js | 4 ++ package.json | 1 + 7 files changed, 201 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/build.yaml create mode 100644 .gitignore create mode 100644 docker/Dockerfile create mode 100644 docker/default.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..252089de --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +out/ \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..68384552 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,40 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +name: Build +on: + push: + branches: + - main + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: eventmesh/eventmesh-dashboard:latest + file: ./docker/Dockerfile + context: ./ diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7415ebb1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,131 @@ +# https://github.com/github/gitignore/blob/main/Node.gitignore +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..9d27db78 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,10 @@ +FROM node:18.15 as builder +WORKDIR /build +COPY . . +RUN npm install +RUN npm run build +RUN npm run export + +FROM nginx:stable-alpine +COPY docker/default.conf /etc/nginx/conf.d/default.conf +COPY --from=builder /build/out /usr/share/nginx/html diff --git a/docker/default.conf b/docker/default.conf new file mode 100644 index 00000000..50b4e8eb --- /dev/null +++ b/docker/default.conf @@ -0,0 +1,13 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + root /usr/share/nginx/html; + location / { + try_files $uri $uri.html $uri/ =404; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/next.config.js b/next.config.js index b0f480c7..f18ab53b 100644 --- a/next.config.js +++ b/next.config.js @@ -20,6 +20,10 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + typescript: { + // ignore editorRef.current.getValue() error + ignoreBuildErrors: true, + }, } module.exports = nextConfig diff --git a/package.json b/package.json index 22d8dc87..e1771039 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "next dev", "build": "next build", + "export": "next export", "start": "next start", "lint": "eslint . --cache --fix --ext .ts,.tsx" },