-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from wri/docker-build-publish
Build docker image and publish to GHCR
- Loading branch information
Showing
4 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Build and Publish Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- docker-build-publish | ||
|
||
env: | ||
REGISTRY: public.ecr.aws/b7u8b0a6 | ||
IMAGE_NAME: project-zeno/zeno | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Login to Amazon ECR Public | ||
id: login-ecr-public | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
with: | ||
registry-type: public | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM python:3.12-slim-bookworm | ||
|
||
# Set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
# The installer requires curl (and certificates) to download the release archive | ||
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ADD https://astral.sh/uv/0.5.4/install.sh /uv-installer.sh | ||
|
||
# Run the installer then remove it | ||
RUN sh /uv-installer.sh && rm /uv-installer.sh | ||
|
||
# Ensure the installed binary is on the `PATH` | ||
ENV PATH="/root/.local/bin/:$PATH" | ||
|
||
# Copy the project into the image | ||
ADD . /app | ||
|
||
# Sync the project into a new environment, using the frozen lockfile | ||
WORKDIR /app | ||
|
||
# Install the dependencies | ||
RUN uv sync --frozen | ||
|
||
# Command to run the application. | ||
CMD ["uv", "run", "uvicorn", "api:app", "--reload"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters