Skip to content

Commit

Permalink
update to latest microservice deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Jan 14, 2025
1 parent 2336464 commit cf1005e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 78 deletions.
95 changes: 21 additions & 74 deletions .github/workflows/deploy-microservices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,86 +4,33 @@ on:
workflow_dispatch:

jobs:
get-microservice-versions:
deploy-gateway-microservice:
runs-on: ubuntu-latest
environment: pipeline-env
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Step 5: Extract API container version
- name: Extract API container version
id: extract_api_version
run: |
API_VERSION=$(python -B .github/parse_container_version.py gateway)
echo "API_VERSION=$API_VERSION" >> $GITHUB_ENV
echo "API Version: $API_VERSION"
# Step 6: Extract worker container version
- name: Extract worker container version
id: extract_worker_version
run: |
WORKER_VERSION=$(python -B .github/parse_container_version.py worker)
echo "WORKER_VERSION=$WORKER_VERSION" >> $GITHUB_ENV
echo "WORKER Version: $WORKER_VERSION"
# Step 7: Debug output of extracted versions
- name: Debug output of extracted versions
- name: Checkout code
uses: actions/checkout@v2
- name: Log in to GHCR
run: echo "${{ secrets.REPO_ADMIN_GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.REPO_ADMIN_GH_USERNAME }}" --password-stdin
- name: Build gateway service
run: |
echo "API_VERSION=${{ env.API_VERSION }}"
echo "WORKER_VERSION=${{ env.WORKER_VERSION }}"
GATEWAY_VERSION=$(python -B .github/parse_container_version.py gateway)
GATEWAY_IMG="${{ vars.IMG_ROOT }}-gateway:$GATEWAY_VERSION"
docker build --no-cache -f ./gateway/Dockerfile-gateway -t $GATEWAY_IMG .
docker push $GATEWAY_IMG
build-microservice-images:
needs: get-microservice-versions
deploy-worker-microservice:
needs: deploy-gateway-microservice
runs-on: ubuntu-latest
environment: pipeline-env
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Checkout code
uses: actions/checkout@v2
- name: Log in to GHCR
run: echo "${{ secrets.REPO_ADMIN_GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.REPO_ADMIN_GH_USERNAME }}" --password-stdin

- name: Install dependencies
- name: Build worker service
run: |
python -m pip install --upgrade pip
pip install -r assets/pipeline/config/requirements.github.cd.txt
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version # Check if Docker Compose is installed correctly
- name: Authorize push script
run: chmod +x ./assets/docker/scripts/push_image.sh

- name: Build API microservice image
run: |
sudo rm -rf gateway/__pycache__
docker-compose build gateway
- name: Deploy API microservice container to GHCR
run: |
./assets/docker/scripts/push_image.sh gateway ${{ env.API_VERSION }}
env:
REPO_ADMIN_GH_USERNAME: ${{ secrets.REPO_ADMIN_GH_USERNAME }}
REPO_ADMIN_GHCR_TOKEN: ${{ secrets.REPO_ADMIN_GHCR_TOKEN }}

- name: Build worker microservice image
run: |
sudo rm -rf worker/__pycache__
docker-compose build worker
- name: Deploy worker microservice container to GHCR
run: |
./assets/docker/scripts/push_image.sh worker ${{ env.WORKER_VERSION }}
env:
REPO_ADMIN_GH_USERNAME: ${{ secrets.REPO_ADMIN_GH_USERNAME }}
REPO_ADMIN_GHCR_TOKEN: ${{ secrets.REPO_ADMIN_GHCR_TOKEN }}
WORKER_VERSION=$(python -B .github/parse_container_version.py worker)
WORKER_IMG="${{ vars.IMG_ROOT }}-worker:$WORKER_VERSION"
docker build --no-cache -f ./worker/Dockerfile-worker -t $WORKER_IMG .
docker push $WORKER_IMG
4 changes: 2 additions & 2 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Build gateway service
run: |
GATEWAY_VERSION=$(python -B .github/parse_container_version.py gateway)
GATEWAY_IMG="${{ vars.IMG_ROOT }}-gateway:$GATEWAY_VERSION-dev"
GATEWAY_IMG="${{ vars.IMG_ROOT }}-gateway:$GATEWAY_VERSION"
docker build --no-cache -f ./gateway/Dockerfile-gateway -t $GATEWAY_IMG .
docker push $GATEWAY_IMG
Expand All @@ -63,6 +63,6 @@ jobs:
- name: Build worker service
run: |
WORKER_VERSION=$(python -B .github/parse_container_version.py worker)
WORKER_IMG="${{ vars.IMG_ROOT }}-worker:$WORKER_VERSION-dev"
WORKER_IMG="${{ vars.IMG_ROOT }}-worker:$WORKER_VERSION"
docker build --no-cache -f ./worker/Dockerfile-worker -t $WORKER_IMG .
docker push $WORKER_IMG
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
build:
context: .
dockerfile: ./gateway/Dockerfile-gateway
image: ghcr.io/biosimulators/bio-compose-server-gateway:0.0.6-dev # STABLE is 0.0.5-dev
image: ghcr.io/biosimulators/bio-compose-server-gateway:0.0.7-dev # STABLE is 0.0.5-dev
container_name: gateway
networks:
- compnet
Expand All @@ -26,7 +26,7 @@ services:
build:
context: .
dockerfile: ./worker/Dockerfile-worker
image: ghcr.io/biosimulators/bio-compose-server-worker:0.0.2-dev
image: ghcr.io/biosimulators/bio-compose-server-worker:0.0.3-dev # STABLE is 0.0.2-dev
container_name: worker
networks:
- compnet
Expand Down

0 comments on commit cf1005e

Please sign in to comment.