Skip to content

Commit

Permalink
Updates and tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagee committed Mar 12, 2024
1 parent bf974bd commit e74b5a0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/ghcr-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,44 @@ on:
# - cron: '30 22 * * *'
push:
branches: [ main ]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: nmagee/fastapi-demo
IMAGE_TAG: 1.${{ github.run_number }} # GITHUB_RUN_NUMBER }}

jobs:
build-push-docker:

build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1
- name: Checkout
uses: actions/checkout@v4

- name: Set ENV
run: echo "IMAGE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PAT }}

# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v2
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
# ghcr.io/nmagee/fastapi-demo:1.7
tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
labels: ${{ steps.meta.outputs.labels }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7-alpine3.8
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-alpine3.14-2024-01-22

COPY ./app /app
COPY requirements.txt requirements.txt
RUN pip install --upgrade pip && pip install -r requirements.txt
RUN pip install --upgrade pip && pip install -r requirements.txt
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ fastapi
typing
pydantic
boto3
requests
requests

0 comments on commit e74b5a0

Please sign in to comment.