@@ -3,7 +3,7 @@ name: Build_Subgen_Dockerfile
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'launcher'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- '**.yml'
|
- '**.yml'
|
||||||
@@ -13,67 +13,15 @@ jobs:
|
|||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3.0.0
|
uses: docker/login-action@v3.0.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
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 }}
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
push: true
|
push: true
|
||||||
tags: mccloud/subgen:latest
|
tags: mccloud/subgen:launcher
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ RUN apt-get update \
|
|||||||
accelerate \
|
accelerate \
|
||||||
optimum
|
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 [ "bash", "-c", "python3 -u launcher.py && python3 -u subgen.py" ]
|
||||||
|
|
||||||
EXPOSE 8090
|
EXPOSE 8090
|
||||||
|
|||||||
37
launcher.py
Normal file
37
launcher.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
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 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(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.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user