From ed626eedaee0ed155c8628d18a5384af5a032aa9 Mon Sep 17 00:00:00 2001 From: Brian Walsh Date: Wed, 16 Oct 2024 14:47:43 -0700 Subject: [PATCH] improve docker, quay --- .github/workflows/build.yaml | 2 +- Dockerfile | 23 ++++++++++++++++------- pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 906a403..6e8822d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,7 +27,7 @@ jobs: # Login to Quay.io and build image docker login quay.io - docker build -t $REPO:$BRANCH . + docker build --build-arg GITHUB_SHA=$GITHUB_SHA -t $REPO:$BRANCH . # Add 'latest' tag to 'main' image if [[ $BRANCH == 'main' ]]; then diff --git a/Dockerfile b/Dockerfile index 23a3ff6..fab88a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,21 @@ FROM python:3.12 -WORKDIR /app +ARG GITHUB_SHA +ENV GITHUB_SHA=$GITHUB_SHA -ADD "https://api.github.com/repos/ACED-IDP/image_viewer/commits?per_page=1" latest_commit - -RUN git clone https://github.com/ACED-IDP/image_viewer WORKDIR /app/image_viewer -RUN git checkout development -RUN pip install --no-cache-dir . -RUN git log --oneline +# Copy the project files into the container +COPY pyproject.toml ./ + +RUN pip install . + +# write git commit hash to a file +RUN echo $GITHUB_SHA > git_commit_hash.txt + +# Copy the rest of the project files into the container +COPY . . + +# Expose the port your app listens on +EXPOSE 8000 + CMD ["uvicorn", "image_viewer.app:app", "--reload"] diff --git a/pyproject.toml b/pyproject.toml index 455d719..c5fef2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "image_viewer" version = "0.1.0" description = "A FastAPI project for viewing images" authors = [ - { name = "Your Name", email = "your.email@example.com" } + { name = "Brian Walsh", email = "walsbr@ohsu.edu" } ] dependencies = [ "fastapi",