Skip to content

Commit

Permalink
updated worker workflow for deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Duncan Ragsdale <[email protected]>
  • Loading branch information
Thistleman committed Mar 12, 2024
1 parent 30e4483 commit 5fadeeb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/deployworker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ env:
ECS_WORKER_SERVICE: valhub-worker-service
ECS_WORKER_CLUSTER: pv-validation-hub-worker-cluster
WORKER_CONTAINER_NAME: pv-validation-hub-worker-task
AK: ${{ secrets.API_AK }}
SAK: ${{ secrets.API_SAK }}

jobs:
deploy_worker:
Expand Down Expand Up @@ -39,17 +41,27 @@ jobs:
ECR_REPOSITORY: ${{ env.ECR_WORKER_REPOSITORY }}
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
--build-arg region=${{ env.AWS_REGION }} \
--build-arg ak=${{ env.AK }} \
--build-arg sak=${{ env.SAK }} \
-f Dockerfile.prod .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "{image}={$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_ENV
# needed for the task-definition.json file, update task family here
# can also use the CLI to manually generate the task, new def forces new deployment of containers
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition ${{ env.WORKER_CONTAINER_NAME }} --query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ env.WORKER_CONTAINER_NAME }}
image: ${{ steps.build-image-worker.outputs.image }}
image: ${{ env.IMAGE }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
Expand Down
16 changes: 14 additions & 2 deletions workers/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ FROM python:3.10-slim as base
# docker build --progress=plain -t "hmm:Dockerfile" -f valhub/Dockerfile .
WORKDIR /root

RUN apt-get update && apt-get install -y gawk

ARG region=us-west-2
ARG ak
ARG sak
# Copy AWS configuration if needed
RUN mkdir -p .aws
COPY .aws /root/.aws

RUN mkdir worker

WORKDIR /root/.aws

RUN awk -v ak="${ak}" -v sak="${sak}" \
'BEGIN {print "[default]\naws_access_key_id = " ak "\naws_secret_access_key = " sak > "/root/.aws/credentials"}'

RUN awk -v region=${region} \
'BEGIN {print "[default]\nregion = " region > "/root/.aws/config"}'

WORKDIR /root/worker
COPY . .

Expand Down

0 comments on commit 5fadeeb

Please sign in to comment.