Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
fix: 尝试使用交叉编译加快构建过程
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Jun 25, 2022
1 parent 8f80445 commit 46d373d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,19 @@ jobs:
with:
go-version: 1.16
-
name: Tests & build
name: Tests
run: |
go mod tidy
go test -v ./...
-
name: Build
if: success() && startsWith(github.ref, 'refs/tags/')
run: |
GOOS=linux GOARCH=amd64 go build -o opqbot-manager-amd64 -ldflags="-s -w" .
GOOS=linux GOARCH=arm go build -o opqbot-manager-arm -ldflags="-s -w" .
GOOS=linux GOARCH=arm64 go build -o opqbot-manager-arm64 -ldflags="-s -w" .
GOOS=linux GOARCH=386 go build -o opqbot-manager-386 -ldflags="-s -w" .
ls
-
name: Set up QEMU
if: success() && startsWith(github.ref, 'refs/tags/')
Expand Down
48 changes: 42 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,54 @@
FROM golang:alpine AS build
WORKDIR $GOPATH/src
#FROM golang:alpine AS build
#WORKDIR $GOPATH/src
FROM alpine:latest AS build
WORKDIR /apps
ARG TARGETPLATFORM
ARG BUILDPLATFORM
COPY . .
RUN go mod tidy\
&& go build -o opqbot-manager -ldflags="-s -w" . \
&& apk add upx \
RUN ls -lh && echo $TARGETPLATFORM \
&& [[ "$TARGETPLATFORM" == "linux/amd64" ]] \
&& mv /apps/opqbot-manager-amd64 /apps/opqbot-manager || echo "not amd64" \
&& [[ "$TARGETPLATFORM" == "linux/arm64" ]] \
&& mv /apps/opqbot-manager-arm64 /apps/opqbot-manager || echo "not arm64" \
&& [[ "$TARGETPLATFORM" == "linux/arm/v7" ]] \
&& mv /apps/opqbot-manager-arm /apps/opqbot-manager || echo "not arm" \
&& [[ "$TARGETPLATFORM" == "linux/386" ]] \
&& mv /apps/opqbot-manager-386 /apps/opqbot-manager || echo "not 386"



# if [[ "$TARGETPLATFORM" = "linux/amd64" ]]; \
# then \
# mv ./opqbot-manager-amd64 ./opqbot-manager; \
# fi \
# && if ["$TARGETPLATFORM" = "linux/arm64"]; \
# then \
# mv ./opqbot-manager-arm64 ./opqbot-manager; \
# fi \
# && if ["$TARGETPLATFORM" = "linux/arm/v7"]; \
# then \
# mv ./opqbot-manager-arm ./opqbot-manager; \
# fi \
# && if ["$TARGETPLATFORM" = "linux/386"]; \
# then \
# mv ./opqbot-manager-386 ./opqbot-manager; \
# fi

RUN apk add upx \
&& upx opqbot-manager \
|| echo "UPX Install Failed!"
# RUN go mod tidy\
# && go build -o opqbot-manager -ldflags="-s -w" . \
# && apk add upx \
# && upx opqbot-manager \
# || echo "UPX Install Failed!"

FROM alpine:latest
LABEL MAINTAINER enjoy<i@mcenjoy.cn>
ENV VERSION 1.0
# create a new dir
WORKDIR /apps
COPY --from=build /go/src/opqbot-manager /apps/opqbot-manager
COPY --from=build /apps/opqbot-manager /apps/opqbot-manager

COPY config.yaml.example /apps/config.yaml.example

Expand Down

0 comments on commit 46d373d

Please sign in to comment.