Skip to content

Commit

Permalink
multi platform added
Browse files Browse the repository at this point in the history
  • Loading branch information
csalialtog committed Oct 15, 2024
1 parent 073b1cb commit d7a5990
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
45 changes: 27 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
name: Main
name: Build and Push sqlapi

on: [push]

env:
NAME: techciceksepeti/sqlapi
VERSION_PREFIX: 2.0
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
on:
push

jobs:
build:
runs-on: ubuntu-latest

env:
SQLAPI: techciceksepeti/sqlapi
TAG_SQLAPI: 2.8-multi-platform

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Build
- name: Set environment variables
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
run: |
docker build --rm=false -t $NAME .
docker tag $NAME $NAME:latest
docker tag $NAME $NAME:$VERSION_PREFIX.$GITHUB_RUN_NUMBER
echo "$SECRETS_CONTEXT" | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Push
- name: Build and Push sqlapi Docker Image
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push $NAME:latest
docker push $NAME:$VERSION_PREFIX.$GITHUB_RUN_NUMBER
bash ./build-image-multi-platform.sh $SQLAPI Dockerfile $TAG_SQLAPI
17 changes: 17 additions & 0 deletions build-image-multi-platform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

NAME=$1
DOCKERFILE=$2
TAG=$3
PLATFORM=${4:-linux/amd64,linux/arm64} # Default platform is linux/amd64 and linux/arm64 if not specified

if [ $TAG ]; then
echo "Building dockerfile $DOCKERFILE for $NAME:$TAG on platforms $PLATFORM"
docker buildx build --rm=false --file ./images/$DOCKERFILE --platform $PLATFORM -t $NAME:$TAG ./images/. --push
else
echo "Building dockerfile $DOCKERFILE for $NAME on platforms $PLATFORM"
docker buildx build --rm=false --file ./images/$DOCKERFILE --platform $PLATFORM -t $NAME ./images/. --push
docker tag $NAME $NAME:latest
docker tag $NAME $NAME:$BUILDPREFIX$GITHUB_RUN_NUMBER
fi

0 comments on commit d7a5990

Please sign in to comment.