Skip to content

Commit

Permalink
change gh actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
praxxus11 committed Aug 5, 2024
1 parent 4b97fbb commit 4f977d9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 49 deletions.
93 changes: 46 additions & 47 deletions .github/workflows/build-deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,40 @@ env:
GITLAB_REGISTRY_TOKEN: ${{ secrets.GITLAB_REGISTRY_TOKEN }}

jobs:
build-gateway:
runs-on: ubuntu-20.04
steps:
- name: Check out repo.
uses: actions/checkout@v4
- name: Setup buildx
run: docker buildx create --use
- name: Sign in to segmentation gitlab registry.
run: echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
- name: Build gateway image.
run: |
docker buildx build \
--platform linux/arm64 \
--tag registry.gitlab.com/segmentation964330/service/gateway \
--push \
./gateway
build-nginx:
runs-on: ubuntu-20.04
steps:
- name: Check out repo.
uses: actions/checkout@v4
- name: Setup buildx
run: docker buildx create --use
- name: Sign in to segmentation gitlab registry.
run: echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
- name: Build nginx image.
run: |
docker buildx build \
--platform linux/arm64 \
--tag registry.gitlab.com/segmentation964330/service/nginx \
--push \
./nginx
# build-gateway:
# runs-on: ubuntu-20.04
# steps:
# - name: Check out repo.
# uses: actions/checkout@v4
# - name: Setup buildx
# run: docker buildx create --use
# - name: Sign in to segmentation gitlab registry.
# run: echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
# - name: Build gateway image.
# run: |
# docker buildx build \
# --platform linux/arm64 \
# --tag registry.gitlab.com/segmentation964330/service/gateway \
# --push \
# ./gateway
# build-nginx:
# runs-on: ubuntu-20.04
# steps:
# - name: Check out repo.
# uses: actions/checkout@v4
# - name: Setup buildx
# run: docker buildx create --use
# - name: Sign in to segmentation gitlab registry.
# run: echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
# - name: Build nginx image.
# run: |
# docker buildx build \
# --platform linux/arm64 \
# --tag registry.gitlab.com/segmentation964330/service/nginx \
# --push \
# ./nginx
deploy:
runs-on: ubuntu-20.04
needs: [build-gateway, build-nginx]
steps:
- name: Check out repo.
uses: actions/checkout@v4
Expand All @@ -56,18 +55,18 @@ jobs:
host: ${{ secrets.ORACLE_HOST }}
username: ${{ secrets.ORACLE_USERNAME }}
key: ${{ secrets.ORACLE_SSH_KEY }}
source: "./docker-compose.yml"
source: "."
target: "."
- name: Pull docker and deploy.
uses: appleboy/[email protected]
with:
host: ${{ secrets.ORACLE_HOST }}
username: ${{ secrets.ORACLE_USERNAME }}
key: ${{ secrets.ORACLE_SSH_KEY }}
envs: GITLAB_REGISTRY_USERNAME, GITLAB_REGISTRY_TOKEN
script: |
echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
sudo docker compose down
sudo docker compose pull
sudo docker compose up --detach
sudo docker image prune --force
# - name: Pull docker and deploy.
# uses: appleboy/[email protected]
# with:
# host: ${{ secrets.ORACLE_HOST }}
# username: ${{ secrets.ORACLE_USERNAME }}
# key: ${{ secrets.ORACLE_SSH_KEY }}
# envs: GITLAB_REGISTRY_USERNAME, GITLAB_REGISTRY_TOKEN
# script: |
# echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
# sudo docker compose down
# sudo docker compose pull
# sudo docker compose up --detach
# sudo docker image prune --force
4 changes: 2 additions & 2 deletions gateway/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@app.route("/healthcheck")
def hello_world():
logger.info("Healthcheck run.")
return "Hello world!", 200
return "Hello world.", 200

@app.route("/upload", methods=["POST"])
def predict():
Expand All @@ -34,7 +34,7 @@ def predict():
imgname = str(uuid.uuid1()) + '.jpg'
image.save(os.path.join(os.environ['IMAGES_DIR'], imgname))
job_id = job_queue.add_task("inference.infer", imgname)
addr = str(request.environ['REMOTE_ADDR'])
addr = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
logger.info(f"Saved image {imgname} for {addr}.")
return job_id, 200
except Exception as e:
Expand Down

0 comments on commit 4f977d9

Please sign in to comment.