Skip to content

Commit

Permalink
Use multiplatform build
Browse files Browse the repository at this point in the history
  • Loading branch information
Anze committed Nov 9, 2020
1 parent 5ce6c8d commit 1352145
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v1

- name: Set docker build as alias to buildx (multiarch build)
uses: docker/setup-buildx-action@v1
id: buildx
with:
install: true

- name: Deploy to Docker Hub
if: success() && startsWith(github.ref, 'refs/tags/v')
Expand All @@ -22,13 +27,16 @@ jobs:
DOCKER_IMAGE: grafolean/grafolean-snmp-bot
DOCKER_USER: grafolean
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
BUILD_PLATFORMS: linux/amd64,linux/arm/v7
run: |
echo "Available plaftorms: ${{ steps.buildx.outputs.platforms }}"
echo "Building for plaftorms: $BUILD_PLATFORMS"
export VERSION=${GITHUB_REF_TAG:10:50}
echo "Version is $VERSION"
export LAST_KNOWN_VERSION=`git tag -l --sort=-version:refname "v*.*.*" | grep -v rc | head -n 1 | tr -d '[:space:]'`
echo "Last known version is $LAST_KNOWN_VERSION"
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD $DOCKER_REGISTRY
docker build -t "docker.io/$DOCKER_IMAGE:$VERSION" -t "docker.io/$DOCKER_IMAGE:latest" --build-arg VERSION=$VERSION --build-arg VCS_REF=$GITHUB_SHA --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') .
docker build --platform "$BUILD_PLATFORMS" -t "docker.io/$DOCKER_IMAGE:$VERSION" -t "docker.io/$DOCKER_IMAGE:latest" --build-arg VERSION=$VERSION --build-arg VCS_REF=$GITHUB_SHA --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') .
[ "$LAST_KNOWN_VERSION" == "$VERSION" ] && docker tag "docker.io/$DOCKER_IMAGE:$VERSION" "docker.io/$DOCKER_IMAGE:latest" || echo "NOT MARKING AS LATEST!"
docker images
docker push "docker.io/$DOCKER_IMAGE:$VERSION"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ LABEL org.label-schema.vendor="Grafolean" \
COPY --from=python-requirements /requirements.txt /requirements.txt
RUN \
apt-get update && \
apt-get install --no-install-recommends -q -y libsnmp-dev build-essential git && \
apt-get install --no-install-recommends -q -y libsnmp-dev build-essential libpq-dev python3-dev git && \
pip install --no-cache-dir -r /requirements.txt && \
apt-get purge -y build-essential && \
apt-get purge -y build-essential libpq-dev python3-dev && \
apt-get clean autoclean && \
apt-get autoremove --yes && \
rm -rf /var/lib/{apt,dpkg,cache,log}/ && \
Expand Down

0 comments on commit 1352145

Please sign in to comment.