refactor: improve usage with Docker

This commit is contained in:
Sefa Eyeoglu 2022-02-18 23:33:32 +01:00
parent dc6dc8c496
commit 6bbecdce2a
No known key found for this signature in database
GPG Key ID: C10411294912A422
13 changed files with 38 additions and 23 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
.git/
caches/
__pycache__/
public/
polymc/
upstream/

10
.gitignore vendored
View File

@ -1,10 +1,8 @@
public/*/
http_cache
caches/
!caches/*/.keep
__pycache__
config_local.sh
polymc
upstream
forgemaven
forge_cache
__pycache__
*.kdev4
config_local.sh

View File

@ -1,12 +1,14 @@
FROM python:3.10.2-bullseye
RUN pip install cachecontrol iso8601 requests lockfile jsonobject
RUN apt update && apt install -y rsync
RUN pip install cachecontrol iso8601 requests lockfile jsonobject \
&& apt-get update && apt-get install -y rsync
RUN useradd -Ud /app user
USER user
WORKDIR /app
COPY . .
ENV MODE=master
CMD ["/bin/bash", "update.sh"]

0
caches/forge_cache/.keep Normal file
View File

0
caches/forgemaven/.keep Normal file
View File

0
caches/http_cache/.keep Normal file
View File

12
docker-compose.yaml Normal file
View File

@ -0,0 +1,12 @@
version: "3"
services:
meta:
build: .
environment:
MODE: master
volumes:
- "./caches:/app/caches"
- "./upstream:/app/upstream"
- "./polymc:/app/polymc"
- "./public:/app/public"

View File

@ -1,5 +0,0 @@
#!/bin/bash
docker build metaenv -t metaenv
docker run -it --rm -e MODE=master -v $(pwd):/app metaenv:latest ./update.sh

View File

@ -109,13 +109,13 @@ for entry in forgeVersions.versions:
for entry in forgeVersion.mavenFiles:
urlSet.add(GetLibraryDownload(entry))
forever_cache = FileCache('forge_cache', forever=True)
forever_cache = FileCache('caches/forge_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache)
for entry in urlSet:
libraryName = entry.name
folderPath = "forgemaven/%s" % libraryName.getBase()
filePath = "forgemaven/%s" % libraryName.getPath()
folderPath = "caches/forgemaven/%s" % libraryName.getBase()
filePath = "caches/forgemaven/%s" % libraryName.getPath()
if not os.path.isfile(filePath):
os.makedirs(folderPath, exist_ok=True)
rfile = sess.get(entry.url, stream=True)

View File

@ -11,7 +11,7 @@ from fabricutil import *
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
forever_cache = FileCache('http_cache', forever=True)
forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache)
def mkdirs(path):

View File

@ -32,7 +32,7 @@ def filehash(filename, hashtype, blocksize=65536):
hash.update(block)
return hash.hexdigest()
forever_cache = FileCache('http_cache', forever=True)
forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache)
# get the remote version list fragments

View File

@ -18,7 +18,7 @@ UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
forever_cache = FileCache('http_cache', forever=True)
forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache)

View File

@ -8,7 +8,7 @@ from metautil import *
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
forever_cache = FileCache('http_cache', forever=True)
forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache)
def get_version_file(path, url):