mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-24 10:51:27 +00:00
add dockerfile
This commit is contained in:
parent
8f83729125
commit
7951517bcc
4 changed files with 73 additions and 28 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
48
.github/workflows/main.yml
vendored
48
.github/workflows/main.yml
vendored
|
|
@ -10,36 +10,34 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: home
|
||||||
|
IMAGE_NAME_FULL: ghcr.io/nbtca/home
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
# 切换分支
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@master
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Login DockerHub
|
||||||
uses: actions/setup-node@v4
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v3
|
- name: Build and Push to DockerHub
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
version: 8
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
- name: Install Dependent Node Packages
|
no-cache: true
|
||||||
run: pnpm install
|
# target: deploy
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64
|
||||||
- name: build
|
tags: |
|
||||||
run: pnpm run build --base ${{ github.event.repository.name }}
|
${{ env.IMAGE_NAME_FULL }}:latest
|
||||||
|
|
||||||
- name: Deploy # 部署
|
|
||||||
uses: JamesIves/github-pages-deploy-action@v4.5.0
|
|
||||||
with:
|
|
||||||
branch: gh-pages # 部署后提交到那个分支
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
folder: dist
|
|
||||||
clean: true
|
|
||||||
single-commit: true
|
|
||||||
git-config-email: github-actions[bot]@users.noreply.github.com
|
|
||||||
git-config-name: github-actions[bot]
|
|
||||||
|
|
|
||||||
14
Dockerfile
Normal file
14
Dockerfile
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
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 install --frozen-lockfile
|
||||||
|
RUN pnpm run build
|
||||||
|
|
||||||
|
FROM nginx:alpine as deploy
|
||||||
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
31
nginx.conf
Normal file
31
nginx.conf
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_min_length 1000;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
|
error_page 404 /404.html;
|
||||||
|
location = /404.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/index.html =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue