From f7bd8d00872520f9954042fe27cae7a8550fba87 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:22:23 -0700 Subject: [PATCH 01/11] Update github-actions-builddockerfile.yml --- .../github-actions-builddockerfile.yml | 49 +------------------ 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/.github/workflows/github-actions-builddockerfile.yml b/.github/workflows/github-actions-builddockerfile.yml index 1803c90..cc1849c 100644 --- a/.github/workflows/github-actions-builddockerfile.yml +++ b/.github/workflows/github-actions-builddockerfile.yml @@ -3,7 +3,7 @@ name: Build_Subgen_Dockerfile on: push: branches: - - 'main' + - 'launcher' paths-ignore: - '**.md' - '**.yml' @@ -13,46 +13,6 @@ jobs: docker: runs-on: ubuntu-latest steps: - - - name: Check disk space - run: df . -h - - - name: Free disk space - run: | - sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true - sudo rm -rf \ - /usr/share/dotnet /usr/local/lib/android /opt/ghc \ - /usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ - /usr/lib/jvm || true - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - echo "some directories deleted" - sudo apt install aptitude -y >/dev/null 2>&1 - sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \ - esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \ - google-cloud-sdk imagemagick \ - libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \ - mercurial apt-transport-https mono-complete libmysqlclient \ - unixodbc-dev yarn chrpath libssl-dev libxft-dev \ - libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \ - snmp pollinate libpq-dev postgresql-client powershell ruby-full \ - sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \ - -y -f >/dev/null 2>&1 - sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1 - sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true - sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true - sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1 - sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1 - sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1 - sudo apt-get autoremove -y >/dev/null 2>&1 - sudo apt-get autoclean -y >/dev/null 2>&1 - echo "some packages purged" - - - name: Check disk space - run: | - df . -h - name: Login to Docker Hub uses: docker/login-action@v3.0.0 @@ -66,14 +26,9 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@v3 - - uses: docker/setup-buildx-action@v3 - name: Build uses: docker/build-push-action@v5 with: - context: . - cache-from: type=gha - cache-to: type=gha,mode=max push: true - tags: mccloud/subgen:latest + tags: mccloud/subgen:launcher From af72dd1f3520e488ec02a6d0d3edac7de795ecbd Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:22:43 -0700 Subject: [PATCH 02/11] Create launcher.py --- launcher.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 launcher.py diff --git a/launcher.py b/launcher.py new file mode 100644 index 0000000..f4f25cf --- /dev/null +++ b/launcher.py @@ -0,0 +1,34 @@ +import os +import requests + +def convert_to_bool(in_bool): + if isinstance(in_bool, bool): + return in_bool + else: + value = str(in_bool).lower() + return value not in ('false', 'off', '0', 0) + +def download_from_github(url, output_file): + response = requests.get(url) + if response.status_code == 200: + with open(output_file, 'wb') as f: + f.write(response.content) + print(f"File downloaded successfully to {output_file}") + else: + print(f"Failed to download file from {url}") + +def main(): + github_url = "https://raw.githubusercontent.com/McCloudS/subgen/main/subgen/subgen.py" + output_file = "subgen.py" + + # Check if the environment variable is set + github_download_enabled = convert_to_bool(os.getenv("UPDATE", False)) + + if github_download_enabled: + print("Downloading subgen.py from GitHub...") + download_from_github(github_url, output_file) + else: + print("Environment variable UPDATE is not set or set to False, skipping download.") + +if __name__ == "__main__": + main() From 3f8328dd3e4914be437b1f31a86c09c326e21d44 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:23:25 -0700 Subject: [PATCH 03/11] Update Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ff94a3a..145aabf 100755 --- a/Dockerfile +++ b/Dockerfile @@ -23,8 +23,8 @@ RUN apt-get update \ accelerate \ optimum -ADD https://raw.githubusercontent.com/McCloudS/subgen/main/subgen/subgen.py /subgen/subgen.py +ADD https://raw.githubusercontent.com/McCloudS/subgen/main/launcher.py /subgen/launcher.py -CMD [ "python3", "-u", "./subgen.py" ] +CMD [ "python3", "-u", "launcher.py", "python3", "-u", "./subgen.py" ] EXPOSE 8090 From 2abb9d42cb80f452291ab9c61c124ecad7548c99 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:26:46 -0700 Subject: [PATCH 04/11] Update github-actions-builddockerfile.yml --- .github/workflows/github-actions-builddockerfile.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/github-actions-builddockerfile.yml b/.github/workflows/github-actions-builddockerfile.yml index cc1849c..4dacfea 100644 --- a/.github/workflows/github-actions-builddockerfile.yml +++ b/.github/workflows/github-actions-builddockerfile.yml @@ -19,15 +19,8 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Log in to the Github Container registry - uses: docker/login-action@v3.0.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build + name: Build and push uses: docker/build-push-action@v5 with: push: true From f373bf53a26f642af8f39adade20ac0a6f860fae Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:28:59 -0700 Subject: [PATCH 05/11] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 145aabf..1e04bcf 100755 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN apt-get update \ accelerate \ optimum -ADD https://raw.githubusercontent.com/McCloudS/subgen/main/launcher.py /subgen/launcher.py +ADD https://raw.githubusercontent.com/McCloudS/subgen/launcher/launcher.py /subgen/launcher.py CMD [ "python3", "-u", "launcher.py", "python3", "-u", "./subgen.py" ] From fcfc88704c0ce53414b8334bd641d5510dc02a45 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:48:08 -0700 Subject: [PATCH 06/11] Update launcher.py --- launcher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/launcher.py b/launcher.py index f4f25cf..bba8597 100644 --- a/launcher.py +++ b/launcher.py @@ -24,7 +24,10 @@ def main(): # Check if the environment variable is set github_download_enabled = convert_to_bool(os.getenv("UPDATE", False)) - if github_download_enabled: + if not os.path.exists(output_file): + print(f"File {output_file} does not exist. Downloading from GitHub...") + download_from_github(github_url, output_file) + elif github_download_enabled: print("Downloading subgen.py from GitHub...") download_from_github(github_url, output_file) else: From 19922fb88810906c84ee9b8614057bf79cca14b7 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:50:57 -0700 Subject: [PATCH 07/11] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1e04bcf..5187dbb 100755 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,6 @@ RUN apt-get update \ ADD https://raw.githubusercontent.com/McCloudS/subgen/launcher/launcher.py /subgen/launcher.py -CMD [ "python3", "-u", "launcher.py", "python3", "-u", "./subgen.py" ] +CMD [ "python3", "-u", "launcher.py", "&&", "python3", "-u", "subgen.py" ] EXPOSE 8090 From 42c748b33c6a641d5801e607cea86c8016edb5d8 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 09:07:02 -0700 Subject: [PATCH 08/11] Update launcher.py --- launcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher.py b/launcher.py index bba8597..4ef237a 100644 --- a/launcher.py +++ b/launcher.py @@ -28,7 +28,7 @@ def main(): print(f"File {output_file} does not exist. Downloading from GitHub...") download_from_github(github_url, output_file) elif github_download_enabled: - print("Downloading subgen.py from GitHub...") + print(f"File exists, but UPDATE is set to True. Downloading {output_file} from GitHub...") download_from_github(github_url, output_file) else: print("Environment variable UPDATE is not set or set to False, skipping download.") From b9d1fbbfe42204ecc4000913b26343d52c111b8a Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 09:15:58 -0700 Subject: [PATCH 09/11] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5187dbb..abc1530 100755 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,6 @@ RUN apt-get update \ ADD https://raw.githubusercontent.com/McCloudS/subgen/launcher/launcher.py /subgen/launcher.py -CMD [ "python3", "-u", "launcher.py", "&&", "python3", "-u", "subgen.py" ] +CMD [ "bash", "-c", "python3 -u launcher.py && python3 -u subgen.py" ] EXPOSE 8090 From 2b8610ef6f222c653f6e404fda09f59aa3a8e425 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 09:40:20 -0700 Subject: [PATCH 10/11] Update launcher.py --- launcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher.py b/launcher.py index 4ef237a..f382d7f 100644 --- a/launcher.py +++ b/launcher.py @@ -24,7 +24,7 @@ def main(): # Check if the environment variable is set github_download_enabled = convert_to_bool(os.getenv("UPDATE", False)) - if not os.path.exists(output_file): + if not os.path.exists(output_file): print(f"File {output_file} does not exist. Downloading from GitHub...") download_from_github(github_url, output_file) elif github_download_enabled: From 7a8e14573436db89199c8b1d1d025ab4169b3ac4 Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 10:03:46 -0700 Subject: [PATCH 11/11] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index abc1530..18d0f3d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN apt-get update \ accelerate \ optimum -ADD https://raw.githubusercontent.com/McCloudS/subgen/launcher/launcher.py /subgen/launcher.py +ADD https://raw.githubusercontent.com/McCloudS/subgen/main/launcher.py /subgen/launcher.py CMD [ "bash", "-c", "python3 -u launcher.py && python3 -u subgen.py" ]