Skip to content

Commit eb8cb31

Browse files
authored
Merge pull request #204 from xuewenG/dev-image
修改构建和发布流水线
2 parents 9d93e1d + 0cb83fa commit eb8cb31

File tree

6 files changed

+100
-64
lines changed

6 files changed

+100
-64
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/dev.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build And Upload Image For Dev
2+
on:
3+
push:
4+
branches:
5+
- dev
6+
concurrency:
7+
group: ${{ github.workflow }}
8+
cancel-in-progress: false
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Extract Version
16+
run: |
17+
BUILD_TIME=$(TZ='Asia/Shanghai' date +'%Y%m%d%H%M')
18+
COMMIT_ID=${GITHUB_SHA:0:7}
19+
VERSION=dev.$BUILD_TIME.$COMMIT_ID
20+
echo VERSION=$VERSION >> $GITHUB_ENV
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v3
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
- name: Login to DockerHub
26+
uses: docker/login-action@v3
27+
with:
28+
username: ${{ secrets.DOCKER_USER_NAME }}
29+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
30+
- name: Build and Push Image
31+
uses: docker/build-push-action@v6
32+
with:
33+
push: true
34+
context: .
35+
platforms: |
36+
linux/amd64
37+
linux/arm64
38+
tags: |
39+
${{ secrets.DOCKER_USER_NAME }}/moments:dev
40+
${{ secrets.DOCKER_USER_NAME }}/moments:${{ env.VERSION }}
41+
build-args: |
42+
VERSION=${{ env.VERSION }}

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build And Upload Image For Release
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
concurrency:
7+
group: ${{ github.workflow }}
8+
cancel-in-progress: false
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Extract Version
16+
run: |
17+
VERSION=${GITHUB_REF#refs/tags/v}
18+
echo VERSION=$VERSION >> $GITHUB_ENV
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
- name: Login to DockerHub
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_USER_NAME }}
27+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
28+
- name: Build and Push Image
29+
uses: docker/build-push-action@v6
30+
with:
31+
push: true
32+
context: .
33+
platforms: |
34+
linux/amd64
35+
linux/arm64
36+
tags: |
37+
${{ secrets.DOCKER_USER_NAME }}/moments:latest
38+
${{ secrets.DOCKER_USER_NAME }}/moments:${{ env.VERSION }}
39+
build-args: |
40+
VERSION=${{ env.VERSION }}

Dockerfile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
FROM node:22.2.0-alpine as front
1+
FROM node:22.2.0-alpine AS front
22
WORKDIR /app
3-
COPY front/package*.json ./
4-
RUN npm install
3+
RUN npm install -g pnpm
4+
COPY front/package.json .
5+
COPY front/pnpm-lock.yaml .
6+
RUN pnpm install
57
COPY front/. .
6-
RUN npm run generate
8+
RUN pnpm run generate
79

8-
FROM golang:1.22.5-alpine as backend
9-
ENV CGO_ENABLED 1
10-
RUN apk add build-base
10+
FROM golang:1.22.5-alpine AS backend
1111
WORKDIR /app
12+
ENV CGO_ENABLED=1
13+
RUN apk add --no-cache build-base tzdata
1214
COPY backend/go.mod .
1315
COPY backend/go.sum .
1416
RUN go mod download
15-
RUN go mod tidy
1617
COPY backend/. .
1718
COPY --from=front /app/.output/public /app/public
18-
RUN apk update --no-cache && apk add --no-cache tzdata
1919
RUN go build -tags prod -ldflags="-s -w" -o /app/moments
2020

2121
FROM alpine
22-
ARG VERSION
23-
RUN apk update --no-cache && apk add --no-cache ca-certificates
24-
COPY --from=backend /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
25-
ENV TZ Asia/Shanghai
2622
WORKDIR /app/data
27-
ENV VERSION $VERSION
23+
RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata
24+
ARG VERSION
25+
ENV PORT=3000
26+
ENV TZ=Asia/Shanghai
27+
ENV VERSION=$VERSION
2828
COPY --from=backend /app/moments /app/moments
29-
ENV PORT 3000
30-
EXPOSE 3000
3129
RUN chmod +x /app/moments
32-
CMD ["/app/moments"]
30+
EXPOSE 3000
31+
CMD ["/app/moments"]

backend/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/kingwrcy/moments
22

3-
go 1.22.4
3+
go 1.22.5
44

55
require (
66
github.com/PuerkitoBio/goquery v1.9.2

front/pages/sys/settings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</div>
88

99
<div class="flex justify-end text-xs text-gray-400">
10-
<div v-if="version">版本号:v{{version }}</div>
10+
<div v-if="version">版本号: {{ version }}</div>
1111
</div>
1212
<UFormGroup label="管理员账号" name="adminUserName" :ui="{label:{base:'font-bold'}}">
1313
<UInput v-model="state.adminUserName"/>

0 commit comments

Comments
 (0)