add product_item

This commit is contained in:
王性驊 2025-04-10 15:54:58 +08:00
parent 61870ec7a2
commit 8b0aa7a0db
2 changed files with 14 additions and 5 deletions

View File

@ -1,7 +1,7 @@
###########
# BUILDER #
###########
FROM golang:1.24.0 as builder
FROM golang:1.24.2 AS builder
ARG VERSION
ARG BUILT
@ -25,14 +25,22 @@ RUN mkdir -p /root/.ssh && \
echo "$SSH_PRV_KEY" > /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa
RUN --mount=type=ssh go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "$FLAG" \
-o product
##########
## upx ##
#########
# 壓縮執行黨,讓他變小
FROM gruebel/upx:latest as upx
WORKDIR /app
COPY --from=builder /app/product /app/product
# Compress the binary and copy it to final image
RUN upx --best --lzma /app/product
##########
## FINAL #
##########
@ -40,7 +48,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
FROM gcr.io/distroless/static-debian11
WORKDIR /app
COPY --from=builder /app/product /app/product
COPY --from=upx /app/product /app/product
COPY --from=builder /app/etc/product.yaml /app/etc/product.yaml
EXPOSE 8080
CMD ["/app/product"]

3
go.mod
View File

@ -1,10 +1,11 @@
module code.30cm.net/digimon/app-cloudep-product-service
go 1.24.0
go 1.24.2
require (
code.30cm.net/digimon/library-go/errs v1.2.14
code.30cm.net/digimon/library-go/mongo v0.0.9
code.30cm.net/digimon/library-go/mongo v0.0.9
github.com/alicebob/miniredis/v2 v2.34.0
github.com/golang/snappy v0.0.4
github.com/shopspring/decimal v1.4.0