Skip to content

Commit

Permalink
feat: add Proxy-3 and Proxy-4
Browse files Browse the repository at this point in the history
  • Loading branch information
belajarqywok committed Jul 15, 2024
1 parent 776f89e commit 76c3de4
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 2 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/proxy_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,106 @@ jobs:
git push https://$HF_USERNAME:[email protected]/spaces/$HF_USERNAME/$SPACE_NAME main --force
# TebakAja Proxy-3
tebakaja_proxy_space-3:
name: Proxy-3 [ Docker - Hugging Face ]
runs-on: ubuntu-latest
needs: unit_testing

env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
SPACE_NAME: tebakaja_proxy_space-3
HF_USERNAME: qywok
ENDPOINT: qywok-tebakaja-proxy-space-3.hf.space

steps:
- name: Set global directory
run: git config --global --add safe.directory /github/workspace

- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 1000

- name: Check git status
run: git status

- name: Configure git
run: |
git config --local user.email "[email protected]"
git config --local user.name "qywok"
- name: Pull changes from remote
run: |
git pull https://$HF_USERNAME:[email protected]/spaces/$HF_USERNAME/$SPACE_NAME main || \
(git merge --strategy-option theirs)
- name: Change Endpoint
run: |
sed -i "s/192.168.137.1:7860/$ENDPOINT/g" docs/docs.go
sed -i "s/192.168.137.1:7860/$ENDPOINT/g" docs/swagger.json
sed -i "s/192.168.137.1:7860/$ENDPOINT/g" docs/swagger.yaml
- name: Add and commit changes
run: |
git add -A
git diff-index --quiet HEAD || git commit -m "$SPACE_NAME"
- name: Push to Hugging Face
run: |
git push https://$HF_USERNAME:[email protected]/spaces/$HF_USERNAME/$SPACE_NAME main --force
# TebakAja Proxy-4
tebakaja_proxy_space-4:
name: Proxy-4 [ Docker - Hugging Face ]
runs-on: ubuntu-latest
needs: unit_testing

env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
SPACE_NAME: tebakaja_proxy_space-4
HF_USERNAME: qywok
ENDPOINT: qywok-tebakaja-proxy-space-4.hf.space

steps:
- name: Set global directory
run: git config --global --add safe.directory /github/workspace

- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 1000

- name: Check git status
run: git status

- name: Configure git
run: |
git config --local user.email "[email protected]"
git config --local user.name "qywok"
- name: Pull changes from remote
run: |
git pull https://$HF_USERNAME:[email protected]/spaces/$HF_USERNAME/$SPACE_NAME main || \
(git merge --strategy-option theirs)
- name: Change Endpoint
run: |
sed -i "s/192.168.137.1:7860/$ENDPOINT/g" docs/docs.go
sed -i "s/192.168.137.1:7860/$ENDPOINT/g" docs/swagger.json
sed -i "s/192.168.137.1:7860/$ENDPOINT/g" docs/swagger.yaml
- name: Add and commit changes
run: |
git add -A
git diff-index --quiet HEAD || git commit -m "$SPACE_NAME"
- name: Push to Hugging Face
run: |
git push https://$HF_USERNAME:[email protected]/spaces/$HF_USERNAME/$SPACE_NAME main --force
# Functional Testing
functional_testing:
name: Functional Testing
Expand All @@ -185,6 +285,8 @@ jobs:
- tebakaja_proxy_space-0
- tebakaja_proxy_space-1
- tebakaja_proxy_space-2
- tebakaja_proxy_space-3
- tebakaja_proxy_space-4

steps:
- name: Set global directory
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN cat > ${DOTENV} <<EOF
TEBAKAJA_PROXY_HOST=${HOST}
TEBAKAJA_PROXY_PORT=${PORT}

TEBAKAJA_CORS_ALLOW_ORIGINS=https://huggingface.co,https://qywok-tebakaja-proxy-space-0.hf.space,https://qywok-tebakaja-proxy-space-1.hf.space,https://qywok-tebakaja-proxy-space-2.hf.space
TEBAKAJA_CORS_ALLOW_ORIGINS=https://huggingface.co,https://qywok-tebakaja-proxy-space-0.hf.space,https://qywok-tebakaja-proxy-space-1.hf.space,https://qywok-tebakaja-proxy-space-2.hf.space,https://qywok-tebakaja-proxy-space-3.hf.space,https://qywok-tebakaja-proxy-space-4.hf.space
TEBAKAJA_CORS_ALLOW_HEADERS=*
TEBAKAJA_CORS_ALLOW_METHODS=GET,POST
EOF
Expand Down
22 changes: 22 additions & 0 deletions endpoints_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
PROD_ENDPOINT_0="https://qywok-tebakaja-proxy-space-0.hf.space"
PROD_ENDPOINT_1="https://qywok-tebakaja-proxy-space-1.hf.space"
PROD_ENDPOINT_2="https://qywok-tebakaja-proxy-space-2.hf.space"
PROD_ENDPOINT_3="https://qywok-tebakaja-proxy-space-3.hf.space"
PROD_ENDPOINT_4="https://qywok-tebakaja-proxy-space-4.hf.space"


check_status() {
Expand Down Expand Up @@ -61,3 +63,23 @@ make_post_request "$PROD_ENDPOINT_2/crypto/prediction" "{\"days\": 7, \"currency
make_get_request "$PROD_ENDPOINT_2/national-currency/lists" "natcurr-list-prod-2"
make_post_request "$PROD_ENDPOINT_2/national-currency/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "natcurr-prediction-prod-2"
echo " "


echo "-------- [ Proxy 3 ] --------"
make_get_request "$PROD_ENDPOINT_3/stock/lists" "stock-list-prod-3"
make_post_request "$PROD_ENDPOINT_3/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-3"
make_get_request "$PROD_ENDPOINT_3/crypto/lists" "crypto-list-prod-3"
make_post_request "$PROD_ENDPOINT_3/crypto/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "crypto-prediction-prod-3"
make_get_request "$PROD_ENDPOINT_3/national-currency/lists" "natcurr-list-prod-3"
make_post_request "$PROD_ENDPOINT_3/national-currency/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "natcurr-prediction-prod-3"
echo " "


echo "-------- [ Proxy 4 ] --------"
make_get_request "$PROD_ENDPOINT_4/stock/lists" "stock-list-prod-4"
make_post_request "$PROD_ENDPOINT_4/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-4"
make_get_request "$PROD_ENDPOINT_4/crypto/lists" "crypto-list-prod-4"
make_post_request "$PROD_ENDPOINT_4/crypto/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "crypto-prediction-prod-4"
make_get_request "$PROD_ENDPOINT_4/national-currency/lists" "natcurr-list-prod-4"
make_post_request "$PROD_ENDPOINT_4/national-currency/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "natcurr-prediction-prod-4"
echo " "
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ func main() {
}))

proxyService.Use(func(c *fiber.Ctx) error {
c.Set("Content-Security-Policy", fmt.Sprintf("frame-ancestors 'self' %s %s %s %s",
c.Set("Content-Security-Policy", fmt.Sprintf("frame-ancestors 'self' %s %s %s %s %s %s",
"https://huggingface.co",
"https://qywok-tebakaja-proxy-space-0.hf.space",
"https://qywok-tebakaja-proxy-space-1.hf.space",
"https://qywok-tebakaja-proxy-space-2.hf.space",
"https://qywok-tebakaja-proxy-space-3.hf.space",
"https://qywok-tebakaja-proxy-space-4.hf.space",
))
return c.Next()
})
Expand Down

0 comments on commit 76c3de4

Please sign in to comment.