Skip to content

Commit

Permalink
Merge pull request #824 from Fenikkusu/master-docker-build
Browse files Browse the repository at this point in the history
Adding Docker Build Actions
  • Loading branch information
kennethjiang authored Oct 7, 2023
2 parents c11beca + 667794e commit 1b57c8b
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 1 deletion.
185 changes: 185 additions & 0 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion ml_api/Dockerfile.base_amd64
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 1b57c8b

Please sign in to comment.