From 667794ef74a2c19b792165ce01ea1bcfce0f9c6f Mon Sep 17 00:00:00 2001 From: Fenikkusu Date: Wed, 4 Oct 2023 00:15:10 -0400 Subject: [PATCH] Building Docker Build Actions - Adding Workflow For Building Various Docker Images --- .github/workflows/build-images.yaml | 185 ++++++++++++++++++++++++++++ ml_api/Dockerfile.base_amd64 | 2 +- 2 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-images.yaml diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml new file mode 100644 index 000000000..c7ae1c15a --- /dev/null +++ b/.github/workflows/build-images.yaml @@ -0,0 +1,185 @@ +name: Building Docker Images +on: [push,pull_request] +# pull_request: +# branches: +# - 'release' +# - 'master' +# push: +# branches: +# - 'release' +# - 'master' +jobs: + generate-semantic-version: + runs-on: ubuntu-latest + container: + image: gittools/gitversion + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run GitVersion + + run: /tools/dotnet-gitversion /output buildserver + + - name: Saving Results + run: | + + REPOSITORY_LC=$(echo "$REPOSITORY" | tr '[:upper:]' '[:lower:]') + GitVersion_FullSemVer_Docker=$(echo "$GitVersion_FullSemVer" | tr '+' '.') + + echo "GitVersion_FullSemVer_Docker=$GitVersion_FullSemVer_Docker" >> gitversion.properties + echo "GitVersion_FullSemVer=$GitVersion_FullSemVer" >> gitversion.properties + echo "GitVersion_LegacySemVer=$GitVersion_LegacySemVer" >> gitversion.properties + echo "GitVersion_Major=$GitVersion_Major" >> gitversion.properties + echo "GitVersion_MajorMinorPatch=$GitVersion_MajorMinorPatch" >> gitversion.properties + echo "GitVersion_Minor=$GitVersion_Minor" >> gitversion.properties + echo "GitVersion_Patch=$GitVersion_Patch" >> gitversion.properties + echo "GitVersion_PreReleaseLabel=$GitVersion_PreReleaseLabel" >> gitversion.properties + echo "GitVersion_PreReleaseNumber=$GitVersion_PreReleaseNumber" >> gitversion.properties + echo "GitVersion_SemVer=$GitVersion_SemVer" >> gitversion.properties + echo "REPOSITORY_LC=$REPOSITORY_LC" >> gitversion.properties + + env: + REPOSITORY: '${{ github.repository }}' + + - uses: actions/upload-artifact@v3 + with: + name: gitversion.properties + path: gitversion.properties + build-base-image: + runs-on: ubuntu-latest + needs: + - generate-semantic-version + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 + with: + name: gitversion.properties + + - name: Load Variables + run: cat gitversion.properties >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + cache-from: | + thespaghettidetective/web:base-1.13 + thespaghettidetective/web:base + ghcr.io/${{ env.REPOSITORY_LC }}/web:base-1.13 + ghcr.io/${{ env.REPOSITORY_LC }}/web:base + context: backend + file: backend/Dockerfile.base + push: true + tags: ghcr.io/${{ env.REPOSITORY_LC }}/web:base-${{ env.GitVersion_FullSemVer_Docker }} + + build-base-ml-image: + runs-on: ubuntu-latest + needs: + - generate-semantic-version + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 + with: + name: gitversion.properties + + - name: Load Variables + run: cat gitversion.properties >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + cache-from: | + thespaghettidetective/ml_api_base:1.3 + thespaghettidetective/ml_api_base + ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base:1.3 + ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base + context: ml_api + file: ml_api/Dockerfile.base_amd64 + push: true + tags: ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base:base-${{ env.GitVersion_FullSemVer_Docker }} + + build-backend-image: + runs-on: ubuntu-latest + needs: + - build-base-image + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 + with: + name: gitversion.properties + + - name: Load Variables + run: cat gitversion.properties >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + cache-from: | + thespaghettidetective/server:base-1.13 + thespaghettidetective/server:base + ghcr.io/${{ env.REPOSITORY_LC }}/server:base-1.13 + ghcr.io/${{ env.REPOSITORY_LC }}/server:base + context: backend + file: backend/Dockerfile + push: true + tags: ghcr.io/${{ env.REPOSITORY_LC }}/server:${{ env.GitVersion_FullSemVer_Docker }} + + build-api-image: + runs-on: ubuntu-latest + needs: + - build-base-ml-image + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 + with: + name: gitversion.properties + + - name: Load Variables + run: cat gitversion.properties >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + cache-from: | + thespaghettidetective/ml:base-1.13 + thespaghettidetective/ml:base + ghcr.io/${{ env.REPOSITORY_LC }}/ml:base-1.13 + ghcr.io/${{ env.REPOSITORY_LC }}/ml:base + context: ml_api + file: ml_api/Dockerfile + push: true + tags: ghcr.io/${{ env.REPOSITORY_LC }}/ml:${{ env.GitVersion_FullSemVer_Docker }} \ No newline at end of file diff --git a/ml_api/Dockerfile.base_amd64 b/ml_api/Dockerfile.base_amd64 index 217d8d10c..5d4d7a886 100644 --- a/ml_api/Dockerfile.base_amd64 +++ b/ml_api/Dockerfile.base_amd64 @@ -7,7 +7,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt update && apt install -y ca-certificates build-essential gcc g++ cmake git WORKDIR / # Lock darknet version for reproducibility -RUN git clone https://github.com/AlexeyAB/darknet --depth 1 && cd darknet && git checkout 59c86222c5387bffd9108a21885f80e980ece234 +RUN git clone https://github.com/AlexeyAB/darknet && cd darknet && git checkout 59c86222c5387bffd9108a21885f80e980ece234 # compile GPU version RUN cd darknet \ && sed -i 's/GPU=0/GPU=1/' Makefile \