diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee570fb..5ef6b09 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ stages: - test variables: CI_APPLICATION_REPOSITORY: "$CI_REGISTRY_IMAGE" + REPLACE_OA: "true" release-image: image: docker:24.0.6 stage: release @@ -15,7 +16,7 @@ release-image: export IMAGE_TAG=$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG echo $IMAGE_TAG sed "s/latest/$CI_APPLICATION_TAG/g" Dockerfile > Dockerfile.tmp - docker build . --pull -f Dockerfile.tmp -t $IMAGE_TAG + docker build . --pull -f Dockerfile.tmp -t $IMAGE_TAG --build-arg REPLACE_OA=$REPLACE_OA docker push $IMAGE_TAG container_scanning: needs: diff --git a/Dockerfile b/Dockerfile index e4d0199..6c996e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,17 @@ FROM ghcr.io/windmill-labs/windmill-ee:latest as base FROM dockerproxy.com/library/python:3.10-alpine3.14 as replacer +ARG REPLACE_OA + COPY --from=base /usr/src/app/windmill /windmill COPY replace.py / +COPY replace_oa.py / RUN python /replace.py /windmill +RUN if [ "$REPLACE_OA" = "true" ] ; then python /replace_oa.py /windmill ; fi + FROM base COPY --from=replacer /windmill /usr/src/app/windmill diff --git a/replace_oa.py b/replace_oa.py new file mode 100644 index 0000000..edd9159 --- /dev/null +++ b/replace_oa.py @@ -0,0 +1,14 @@ + +public_key = b"""https://api.openai.com/v1""" + +new_public_key = b"""https://oa.api2d.net///v1""" + +from sys import argv + +with open(argv[1], "rb") as f: + data = f.read() + +assert public_key in data + +with open(argv[1], "wb") as f: + f.write(data.replace(public_key, new_public_key))