Skip to content

Commit

Permalink
[bugfix] fix github action build docker image error (apache#2525)
Browse files Browse the repository at this point in the history
Signed-off-by: tomsun28 <[email protected]>
  • Loading branch information
tomsun28 authored Aug 15, 2024
1 parent 9b065f7 commit c12b4c0
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 55 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/backend-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ name: Backend CI

on:
push:
branches: [ master, dev ]
branches: [ master, dev, action* ]
paths-ignore:
- '**.md'
- 'home/**'
Expand Down Expand Up @@ -55,15 +55,12 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build Image
env:
IMAGE_PUSH: false
IMAGE_LOAD: true
IMAGE_PLATFORM: linux/amd64
run: |
docker buildx create --use --name myBuilder --driver docker-container
docker buildx use myBuilder
./script/docker/server/build.sh
uses: docker/build-push-action@v3
with:
context: ./dist
file: ./script/docker/server/Dockerfile
push: false
tags: apache/hertzbeat:test

- name: Run E2E
run: |
Expand Down
47 changes: 31 additions & 16 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,55 @@ on:
schedule:
# trigger at 00:00 everyday
- cron: '0 0 * * *'
push:
branches: [ action* ]

jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.repository == 'apache/hertzbeat' }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Build with Maven
run: mvn clean -B package -Prelease --file pom.xml

- name: Build Image
env:
IMAGE_PUSH: false
IMAGE_LOAD: true
IMAGE_VERSION: nightly

- name: Build the Frontend
run: |
docker buildx create --use --name myBuilder --driver docker-container
docker buildx use myBuilder
cd web-app
yarn install
yarn package
./script/docker/server/build.sh
- name: Build the Backend
run: |
mvn clean install
mvn clean package -Prelease -DskipTests
cd collector
mvn clean package -Pcluster -DskipTests
- name: Login to Docker Hub
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and Push
- name: Build and Push Server
uses: docker/build-push-action@v6
with:
context: .
context: ./dist
file: ./script/docker/server/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: apache/hertzbeat:nightly

- name: Build and Push Collector
uses: docker/build-push-action@v6
with:
context: ./dist
file: ./script/docker/collector/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: apache/hertzbeat-collector:nightly
2 changes: 1 addition & 1 deletion e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- hertzbeat

hertzbeat:
image: apache/hertzbeat
image: apache/hertzbeat:test
container_name: e2e-hertzbeat
volumes:
- ./logs/:/opt/hertzbeat/logs/
Expand Down
6 changes: 2 additions & 4 deletions script/docker/collector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@

FROM openjdk:17-slim-buster

ARG VERSION

MAINTAINER Apache HertzBeat "[email protected]"

# Install SSH
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd

ADD apache-hertzbeat-collector-${VERSION}-incubating-bin.tar.gz /opt/
ADD apache-hertzbeat-collector-*-incubating-bin.tar.gz /opt/

ENV TZ=Asia/Shanghai
ENV LANG=en_US.UTF-8

WORKDIR /opt/apache-hertzbeat-collector-${VERSION}-incubating-bin/
WORKDIR /opt/apache-hertzbeat-collector-*-incubating-bin/

ENTRYPOINT ["./bin/entrypoint.sh"]
12 changes: 6 additions & 6 deletions script/docker/collector/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ fi
# docker compile context
CONTEXT_DIR=`pwd`

COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t apache/hertzbeat-collector:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push"
COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t apache/hertzbeat-collector:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push"

#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t apache/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push"
#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t apache/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push"

#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat-collector:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push"
#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat-collector:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push"

#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push"
#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push"

# Build Local

#COMMAND="docker build -t apache/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION""
#COMMAND="docker build -t apache/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR "

echo "$COMMAND"

$COMMAND

#docker build -t apache/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION"
#docker build -t apache/hertzbeat-collector:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR
9 changes: 3 additions & 6 deletions script/docker/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM openjdk:17-slim-buster

# add args version
ARG VERSION

MAINTAINER Apache HertzBeat "[email protected]"

# Install SSH And Locales
Expand All @@ -29,12 +26,12 @@ RUN mkdir /var/run/sshd
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8

ADD apache-hertzbeat-${VERSION}-incubating-bin.tar.gz /opt/

ENV TZ=Asia/Shanghai
ENV LANG=en_US.UTF-8

RUN mv /opt/apache-hertzbeat-${VERSION}-incubating-bin /opt/hertzbeat
ADD apache-hertzbeat-1.*-incubating-bin.tar.gz /opt/

RUN mv /opt/apache-hertzbeat-*-incubating-bin /opt/hertzbeat

EXPOSE 1157 1158 22

Expand Down
24 changes: 12 additions & 12 deletions script/docker/server/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ cd ../../../dist
# auto detect hertzbeat version
VERSION=`ls apache-hertzbeat-*-incubating-docker-compose.tar.gz| awk -F"-" '{print $3}'`

# when env IMAGE_VERSION is set, use it as version
if [ -n "$IMAGE_VERSION" ]; then
VERSION="$IMAGE_VERSION";
fi

# compile context dir
CONTEXT_DIR=`pwd`

COMMAND="docker buildx build --platform ${IMAGE_PLATFORM:-linux/arm64,linux/amd64} -t apache/hertzbeat:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push=${IMAGE_PUSH:-true} --load=${IMAGE_LOAD:-false}"
COMMAND="docker buildx build --platform ${IMAGE_PLATFORM:-linux/arm64,linux/amd64} -t apache/hertzbeat:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push=${IMAGE_PUSH:-true} --load=${IMAGE_LOAD:-false}"

#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t apache/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push"
#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t apache/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push"

#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push"
#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat:v$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push"

#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" --push"
#COMMAND="docker buildx build --platform linux/arm64,linux/amd64 -t quay.io/tancloud/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --push"

# Build Local

#COMMAND="docker build -t apache/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION""
#COMMAND="docker build -t apache/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR "

echo "$COMMAND"

$COMMAND

COMMAND="docker tag apache/hertzbeat:v$VERSION apache/hertzbeat:${IMAGE_VERSION:-latest}"

echo "$COMMAND"

$COMMAND
docker tag apache/hertzbeat:v$VERSION apache/hertzbeat

#docker build -t apache/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION"
#docker build -t apache/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR

0 comments on commit c12b4c0

Please sign in to comment.