-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ coverage | |
*.sw? | ||
|
||
*.tsbuildinfo | ||
*/__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters