Skip to content

Commit

Permalink
feat: 添加github action来打包
Browse files Browse the repository at this point in the history
  • Loading branch information
LYouC committed Jan 13, 2025
1 parent b54010e commit 0b75bae
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docker Build and Push

on:
push:
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: ls -la

- name: 登录 Docker
uses: docker/login-action@v3
with:
registry: registry.cn-guangzhou.aliyuncs.com
username: ${{ secrets.ALIYUN_DOCKER_NAME}}
password: ${{ secrets.ALIYUN_PASSWORD }}

- name: 构建 Docker 镜像
uses: docker/build-push-action@v5
with:
push: true
tags: registry.cn-guangzhou.aliyuncs.com/lyouc/test_github_action:v2.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ coverage
*.sw?

*.tsbuildinfo
*/__pycache__/
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 使用Node.js官方镜像作为构建环境
FROM node:18-alpine as build-stage
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install
COPY . .
RUN pnpm run build

# 使用Nginx作为生产环境
FROM python:3.10-slim as production-stage
WORKDIR /app
COPY --from=build-stage /app/dist /app
RUN pip install fastapi uvicorn

EXPOSE 3307
CMD ["uvicorn", "script.main:app", "--host", "0.0.0.0", "--port", "3307"]
10 changes: 10 additions & 0 deletions script/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
import uvicorn

app = FastAPI()

app.mount("/", StaticFiles(directory="./dist"), name="static")

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=3307)
4 changes: 2 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
history: createWebHashHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
Expand Down
8 changes: 3 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
vueDevTools(),
],
base: './',
plugins: [vue(), vueDevTools()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
})

0 comments on commit 0b75bae

Please sign in to comment.