feat: replace oa
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
14
replace_oa.py
Normal file
14
replace_oa.py
Normal file
@@ -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))
|
||||
Reference in New Issue
Block a user