Merge pull request #1 from DDS-Derek/refactor_ci

feat: refactor ci
This commit is contained in:
Simon
2024-07-22 14:03:45 +08:00
committed by GitHub
2 changed files with 30 additions and 20 deletions

View File

@@ -9,7 +9,14 @@ jobs:
build_and_deploy_docker: build_and_deploy_docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
- name: Set Up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to image repository - name: Login to image repository
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
@@ -17,9 +24,26 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }} password: ${{ secrets.GHCR_TOKEN }}
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3
- name: Build Web
run: |
cd ui
flutter pub get
flutter build web
- name: Build and push - name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
with: with:
context: .
file: Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true push: true
tags: ghcr.io/simon-ding/polaris:latest tags: ghcr.io/simon-ding/polaris:latest

View File

@@ -1,13 +1,4 @@
FROM instrumentisto/flutter:3 AS flutter FROM golang:1.22-alpine3.20 as builder
WORKDIR /app
COPY ./ui/pubspec.yaml ./ui/pubspec.lock ./
RUN flutter pub get
COPY ./ui/ ./
RUN flutter build web
# 打包依赖阶段使用golang作为基础镜像
FROM golang:1.22 as builder
# 启用go module # 启用go module
ENV GO111MODULE=on \ ENV GO111MODULE=on \
@@ -15,22 +6,17 @@ ENV GO111MODULE=on \
WORKDIR /app WORKDIR /app
COPY go.mod . COPY go.mod go.sum ./
COPY go.sum .
RUN go mod download RUN go mod download
COPY . . COPY . .
RUN go build -o polaris ./cmd/
COPY --from=flutter /app/build/web ./ui/build/web/ FROM alpine:3.20
# 指定OS等并go build
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o polaris ./cmd/
FROM debian:12
WORKDIR /app WORKDIR /app
RUN apt-get update && apt-get -y install ca-certificates RUN apk add --no-cache bash ca-certificates
# 将上一个阶段publish文件夹下的所有文件复制进来
COPY --from=builder /app/polaris . COPY --from=builder /app/polaris .
EXPOSE 8080 EXPOSE 8080