Skip to content

Commit

Permalink
修改 docker 编译
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdgy committed Jan 29, 2024
1 parent 39b28f2 commit b7fbbdc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@ jobs:
run: uname -a

- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: 'web/yarn.lock'
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache-dependency-path: 'server/go.sum'
- name: Build web
working-directory: web
run: |
yarn install
yarn run build

# - uses: actions/setup-node@v4
# with:
# node-version: '16'
# cache: 'yarn'
# cache-dependency-path: 'web/yarn.lock'
# - uses: actions/setup-go@v4
# with:
# go-version: '1.20'
# cache-dependency-path: 'server/go.sum'
# - name: Build web
# working-directory: web
# run: |
# yarn install
# yarn run build

- name: Set up QEMU
# https://github.com/docker/setup-qemu-action
uses: docker/setup-qemu-action@v3
Expand All @@ -52,6 +54,9 @@ jobs:
echo "APP_VER=$appVer" >> $GITHUB_ENV
echo "commitId=$commitId" >> $GITHUB_ENV
mkdir server/ui
touch server/ui/a.txt
cd server;go mod tidy
- name: Build and push
Expand Down
5 changes: 2 additions & 3 deletions build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ echo $ver

# docker build -t bjdgyc/anylink -f docker/Dockerfile .

docker build -t bjdgyc/anylink --progress=plain --build-arg CN="yes" --build-arg appVer=$ver \
--build-arg commitId=$(git rev-parse HEAD) --build-arg buildDate=$(date --iso-8601=seconds) \
-f docker/Dockerfile .
docker buildx build -t bjdgyc/anylink --progress=plain --build-arg CN="yes" --build-arg appVer=$ver \
--build-arg commitId=$(git rev-parse HEAD) -f docker/Dockerfile .

docker tag bjdgyc/anylink:latest bjdgyc/anylink:$ver
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ COPY docker/init.sh /tmp/init.sh
COPY server/ /server/
COPY web/ui /server/ui

RUN apk add gcc musl-dev bash
RUN bash /tmp/init.sh
#RUN apk add gcc musl-dev bash
RUN sh /tmp/init.sh


# anylink
Expand Down
9 changes: 6 additions & 3 deletions docker/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ if [[ $CN == "yes" ]]; then
export GOPROXY=https://goproxy.cn
fi

#apk add gcc musl-dev
apk add tzdata gcc musl-dev

uname -a
env
date

cd /server

go mod tidy

echo "start build"

#-extldflags '-static'

ldflags="-s -w -X main.appVer=$appVer -X main.commitId=$commitId -X main.buildDate=$(date -Iseconds)"
ldflags="-s -w -extldflags \"-static\" -X main.appVer=$appVer -X main.commitId=$commitId -X main.buildDate=$(date -Iseconds)"

go build -v -o anylink -trimpath -ldflags "$ldflags"
go build -o anylink -trimpath -ldflags "$ldflags"

ls -l /server/

Expand Down

0 comments on commit b7fbbdc

Please sign in to comment.