Skip to content

Commit

Permalink
feat: add Swagger OpenAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
belajarqywok committed Jul 10, 2024
1 parent d3c13b7 commit f118f03
Show file tree
Hide file tree
Showing 17 changed files with 1,366 additions and 31 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/proxy_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
SPACE_NAME: tebakaja_proxy_space-0
HF_USERNAME: qywok
ENDPOINT: qywok-tebakaja-proxy-space-0.hf.space

steps:
- name: Set global directory
Expand All @@ -58,10 +59,16 @@ jobs:
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 "tebakaja_proxy_space-0"
git diff-index --quiet HEAD || git commit -m "$SPACE_NAME"
- name: Push to Hugging Face
run: |
Expand All @@ -78,6 +85,7 @@ jobs:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
SPACE_NAME: tebakaja_proxy_space-1
HF_USERNAME: qywok
ENDPOINT: qywok-tebakaja-proxy-space-1.hf.space

steps:
- name: Set global directory
Expand All @@ -101,10 +109,16 @@ jobs:
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 "tebakaja_proxy_space-1"
git diff-index --quiet HEAD || git commit -m "$SPACE_NAME"
- name: Push to Hugging Face
run: |
Expand All @@ -121,6 +135,7 @@ jobs:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
SPACE_NAME: tebakaja_proxy_space-2
HF_USERNAME: qywok
ENDPOINT: qywok-tebakaja-proxy-space-2.hf.space

steps:
- name: Set global directory
Expand All @@ -144,10 +159,16 @@ jobs:
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 "tebakaja_proxy_space-2"
git diff-index --quiet HEAD || git commit -m "$SPACE_NAME"
- name: Push to Hugging Face
run: |
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ 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

start:
svc:
swag init
go run main.go

swag:
swag init

haproxy-test:
haproxy -f ./haproxy/haproxy.cfg

Expand All @@ -30,6 +34,9 @@ endpoints_check:
# --- Development Testing ---
#

swag-test:
curl -X GET $(DEV_ENDPOINT)/swagger/index.html

stock-list-test:
curl -X GET $(DEV_ENDPOINT)/stock/lists

Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ services:
proxy:
build:
context: .
shm_size : 536870912
dockerfile: Dockerfile
labels :
role : "proxy service"

ports:
- "7860:7860"

Loading

0 comments on commit f118f03

Please sign in to comment.