Skip to content

Commit

Permalink
add tag github workflow, and simplified prod file TODO: Investigate c…
Browse files Browse the repository at this point in the history
…hanging to 1 dockerfile for repo #5
  • Loading branch information
asuresh-code committed Jan 15, 2025
1 parent 05a7082 commit 4e06f88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/.ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI
on:
workflow_dispatch:
inputs:
push-docker-image-to-harbor:
description: 'Push Docker Image to Harbor'
type: boolean
default: false
pull_request:
push:
branches:
Expand Down Expand Up @@ -112,6 +117,8 @@ jobs:
needs: [linting, unit-tests, e2e-tests]
name: Docker
runs-on: ubuntu-latest
env:
PUSH_DOCKER_IMAGE_TO_HARBOR: ${{ inputs.push-docker-image-to-harbor != null && inputs.push-docker-image-to-harbor || 'false' }}
steps:
- name: Check out repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
Expand All @@ -129,11 +136,13 @@ jobs:
with:
images: ${{ secrets.HARBOR_URL }}/object-storage-api

- name: Build and push Docker image to Harbor
- name: ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) && 'Build and push Docker image to Harbor' || 'Build Docker image' }}
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
context: .
file: ./Dockerfile.prod
push: true
push: ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
target: prod

24 changes: 5 additions & 19 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
FROM python:3.12.7-alpine3.20@sha256:edd1d8559c585e1e9a9b79de44ac27f8ac32cb0c7323e112ae6870ceeecd8dbf AS builder

COPY requirements.txt ./

RUN set -eux; \
\
# Install pip dependencies \
python3 -m pip install --no-cache-dir -r requirements.txt;

FROM python:3.12.7-alpine3.20@sha256:edd1d8559c585e1e9a9b79de44ac27f8ac32cb0c7323e112ae6870ceeecd8dbf

WORKDIR /object-storage-api-run

COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin

COPY README.md ./
COPY requirements.txt ./
COPY object_storage_api/ object_storage_api/

RUN set -eux; \
RUN --mount=type=cache,target=/root/.cache \
set -eux; \
\
# Create loging.ini from its .example file \
cp object_storage_api/logging.example.ini object_storage_api/logging.ini;

USER nobody
python3 -m pip install -r requirements.txt;

CMD ["uvicorn", "object_storage_api.main:app", "--app-dir", "/object-storage-api-run", "--host", "0.0.0.0", "--port", "8000"]
CMD ["fastapi", "run", "object_storage_api/main.py", "--host", "0.0.0.0", "--port", "8000"]
EXPOSE 8000

0 comments on commit 4e06f88

Please sign in to comment.