Skip to content

Commit

Permalink
Update Dockerfile and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdlzg committed Jun 18, 2024
1 parent 1a95e99 commit 65284fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-image-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ jobs:
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Build and push Docker images
uses: docker/build-push-action@v3
Expand All @@ -93,3 +91,5 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
FROM node:16 as builder

RUN pwd
WORKDIR /web
run pwd

# 读取 VERSION 文件内容并设置环境变量
RUN echo "VERSION=$(cat ./VERSION)" > .env && \
source .env && \
echo "VERSION=$VERSION"

COPY ./VERSION .
COPY ./web .

WORKDIR /web/default
RUN npm install
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=${VERSION} npm run build

WORKDIR /web/berry
RUN npm install
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=${VERSION} npm run build

WORKDIR /web/air
RUN npm install
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=${VERSION} npm run build

FROM golang AS builder2

Expand All @@ -27,7 +35,7 @@ ADD go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=builder /web/build ./web/build
RUN go build -ldflags "-s -w -X 'github.com/mxdlzg/one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
RUN go build -ldflags "-s -w -X 'github.com/mxdlzg/one-api/common.Version=${VERSION}' -extldflags '-static'" -o one-api

FROM alpine

Expand Down

0 comments on commit 65284fe

Please sign in to comment.