Skip to content

Commit

Permalink
Merge pull request #4 from AllenNeuralDynamics/ci-1-actions-workflow
Browse files Browse the repository at this point in the history
ci: add workflow for docker image publish
  • Loading branch information
yosefmaru committed Apr 5, 2024
2 parents 2312a14 + c64251c commit 7fbef0a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.git
/.github
/.gitignore
/.venv
/venv
58 changes: 58 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Tag and Publish
on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Pull latest changes
run: git pull origin main
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image and push to GitHub Container Registry
uses: docker/build-push-action@v3
with:
# relative path to the place where source code with Dockerfile is located
context: .
push: true
tags: ghcr.io/allenneuraldynamics/anivia:latest
update_ecs_service :
runs-on: ubuntu-latest
needs: publish
permissions:
id-token: write
contents: read
env:
ECS_ROLE: ${{ secrets.AWS_ANIVIA_ECS_ROLE }}
AWS_REGION : ${{ vars.AWS_REGION_DEV }}
ECS_CLUSTER : ${{ vars.AWS_ANIVIA_ECS_CLUSTER }}
ECS_SERVICE : ${{ vars.AWS_ANIVIA_ECS_SERVICE }}
steps:
- uses: actions/checkout@master
- name: Pull latest changes
run: git pull origin main
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.ECS_ROLE }}
role-session-name: github-ecs-update-service
aws-region: ${{ env.AWS_REGION }}
- name: Update ECS service
run: |
python -m pip install awscli
aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.8-slim

WORKDIR /app

COPY . .

RUN apt-get update

EXPOSE 8000

ENTRYPOINT ["python", "-m", "http.server", "8000", "--directory", "src"]

0 comments on commit 7fbef0a

Please sign in to comment.