Spaces:
Running
Running
Commit ·
2eb7aa7
1
Parent(s): 38e062a
Standardize Dockerfile (port 8000) and add GHCR workflow
Browse files- .github/workflows/docker-image-ci.yml +34 -6
- Dockerfile +2 -2
.github/workflows/docker-image-ci.yml
CHANGED
|
@@ -6,13 +6,41 @@ on:
|
|
| 6 |
pull_request:
|
| 7 |
branches: [ "main" ]
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
|
|
|
|
|
|
| 13 |
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
steps:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
pull_request:
|
| 7 |
branches: [ "main" ]
|
| 8 |
|
| 9 |
+
env:
|
| 10 |
+
REGISTRY: ghcr.io
|
| 11 |
+
IMAGE_NAME: ${{ github.repository }}
|
| 12 |
|
| 13 |
+
jobs:
|
| 14 |
+
build-and-push:
|
| 15 |
runs-on: ubuntu-latest
|
| 16 |
+
permissions:
|
| 17 |
+
contents: read
|
| 18 |
+
packages: write
|
| 19 |
|
| 20 |
steps:
|
| 21 |
+
- name: Checkout repository
|
| 22 |
+
uses: actions/checkout@v4
|
| 23 |
+
|
| 24 |
+
- name: Log in to the Container registry
|
| 25 |
+
uses: docker/login-action@v3
|
| 26 |
+
with:
|
| 27 |
+
registry: ${{ env.REGISTRY }}
|
| 28 |
+
username: ${{ github.actor }}
|
| 29 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
| 30 |
+
|
| 31 |
+
- name: Extract metadata (tags, labels) for Docker
|
| 32 |
+
id: meta
|
| 33 |
+
uses: docker/metadata-action@v5
|
| 34 |
+
with:
|
| 35 |
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
| 36 |
+
tags: |
|
| 37 |
+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
| 38 |
+
type=sha
|
| 39 |
+
|
| 40 |
+
- name: Build and push Docker image
|
| 41 |
+
uses: docker/build-push-action@v5
|
| 42 |
+
with:
|
| 43 |
+
context: .
|
| 44 |
+
push: true
|
| 45 |
+
tags: ${{ steps.meta.outputs.tags }}
|
| 46 |
+
labels: ${{ steps.meta.outputs.labels }}
|
Dockerfile
CHANGED
|
@@ -22,6 +22,6 @@ RUN pip install --no-cache-dir --upgrade pip && \
|
|
| 22 |
|
| 23 |
COPY --chown=user . /app
|
| 24 |
|
| 25 |
-
EXPOSE
|
| 26 |
|
| 27 |
-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "
|
|
|
|
| 22 |
|
| 23 |
COPY --chown=user . /app
|
| 24 |
|
| 25 |
+
EXPOSE 8000
|
| 26 |
|
| 27 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--log-level", "info"]
|