From 4e424c45cca4a2114e4723a8d6b8b427f3004394 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 10 Oct 2024 10:55:56 +0800 Subject: [PATCH 1/5] perf: all in dockerfile --- Dockerfile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5c6cff1..d19a40e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,18 @@ -FROM nginx:1.27 +FROM node:20-slim AS base + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable +COPY . /app +WORKDIR /app + +FROM base AS build +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm i --frozen-lockfile +RUN pnpm build + +# Production stage +FROM nginx:stable-alpine as production-stage COPY ./conf/nginx.conf /etc/nginx/conf.d/default.conf -COPY ./dist/ /usr/share/nginx/html +COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From 81369ac9f55375ca99717ffeedf9aa01c955dc91 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 10 Oct 2024 11:00:36 +0800 Subject: [PATCH 2/5] build: dockerignore --- .dockerignore | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..68632d5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,48 @@ +# Node modules +node_modules + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +# Build output +dist +dist-ssr + +# Local env files +.env +.env.* +!.env.example + +# Testing +coverage + +# Misc +*.local + +# Version control +.git +.gitignore + +# Docker +Dockerfile +.dockerignore + +# Temporary files +*.tmp +*.temp \ No newline at end of file From 880be7e7071bea4beee5efc0d2173b214c7b0f9c Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 10 Oct 2024 12:02:55 +0800 Subject: [PATCH 3/5] fix: need to set VITE_GOOGLE_CSE_CX var --- .dockerignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 68632d5..3f3e913 100644 --- a/.dockerignore +++ b/.dockerignore @@ -24,10 +24,10 @@ pnpm-debug.log* dist dist-ssr -# Local env files -.env -.env.* -!.env.example +# # Local env files +# .env +# .env.* +# !.env.example # Testing coverage From 1ffee0b25f93f294939ee7fd31c4ad3b4c60ef9c Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 10 Oct 2024 17:04:13 +0800 Subject: [PATCH 4/5] chore: github action optimisation --- .github/workflows/main.yml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a0dc538..2904fd8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,8 +1,8 @@ on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] env: IMAGE_NAME: luxirty-search jobs: @@ -10,21 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - name: Install pnpm - with: - version: 9 - run_install: false - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - run: pnpm install && pnpm build - + - name: Set up QEMU for multi-architecture builds uses: docker/setup-qemu-action@v2 - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 From 1b73316396ccf8a039215e1335d807cd73be2892 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 10 Oct 2024 17:14:59 +0800 Subject: [PATCH 5/5] test: run github action --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 3f3e913..8cfe0a9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -29,6 +29,7 @@ dist-ssr # .env.* # !.env.example + # Testing coverage