mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
Optimizing Docker image builds (#1)
Co-authored-by: pader.zhang <pader.zhang@starlight-sms.com>
This commit is contained in:
parent
4ce2381182
commit
9adefa80b9
13
Dockerfile
13
Dockerfile
@ -1,4 +1,4 @@
|
||||
FROM node:16 as builder
|
||||
FROM node:16-slim as builder
|
||||
|
||||
WORKDIR /build
|
||||
COPY web/package.json .
|
||||
@ -7,18 +7,19 @@ COPY ./web .
|
||||
COPY ./VERSION .
|
||||
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build
|
||||
|
||||
FROM golang AS builder2
|
||||
|
||||
FROM golang:1.19-alpine AS builder2
|
||||
RUN apk add build-base
|
||||
ENV GO111MODULE=on \
|
||||
CGO_ENABLED=1 \
|
||||
GOOS=linux
|
||||
|
||||
WORKDIR /build
|
||||
ADD go.mod go.sum ./
|
||||
RUN go mod download
|
||||
#ADD go.mod go.sum ./
|
||||
COPY . .
|
||||
COPY --from=builder /build/build ./web/build
|
||||
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
|
||||
|
||||
RUN go mod tidy \
|
||||
&& go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
|
||||
|
||||
FROM alpine
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user