-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions workflow for building and pushing images
- Loading branch information
Showing
6 changed files
with
212 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,40 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
cdaprod/cda-minio-control:latest | ||
ghcr.io/cdaprod/cda-minio-control:latest |
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,19 @@ | ||
FROM python:3.9-slim | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the requirements file to the working directory | ||
COPY requirements.txt . | ||
|
||
# Install the Python dependencies | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy the application code to the working directory | ||
COPY . . | ||
|
||
# Expose the port on which the FastAPI application will run | ||
EXPOSE 8000 | ||
|
||
# Set the command to run the application | ||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] |
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,57 @@ | ||
Dockerizing Instructions | ||
|
||
`docker build -t cdaprod/cda-minio-control .` | ||
|
||
```bash | ||
docker run -p 8000:8000 --name cda-minio-control \ | ||
-e OPENAI_API_KEY=<your-openai-api-key> \ | ||
-e MINIO_ENDPOINT=<your-minio-endpoint> \ | ||
-e MINIO_ACCESS_KEY=<your-minio-access-key> \ | ||
-e MINIO_SECRET_KEY=<your-minio-secret-key> \ | ||
cdaprod/cda-minio-control | ||
``` | ||
|
||
`docker push cdaprod/cda-minio-control` | ||
|
||
```yaml | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
cdaprod/cda-minio-control:latest | ||
ghcr.io/cdaprod/cda-minio-control:latest | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
pydantic | ||
fastapi | ||
uvicorn | ||
minio | ||
weaviate | ||
requests | ||
unstructured | ||
langchain[all] | ||
langserve[all] | ||
docker | ||
openai | ||
langchain | ||
weaviate-client |
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,83 @@ | ||
Sure! Here's a Dockerfile that you can use to containerize your application: | ||
|
||
```Dockerfile | ||
# Use an official Python runtime as the base image | ||
FROM python:3.9-slim | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the requirements file to the working directory | ||
COPY requirements.txt . | ||
|
||
# Install the Python dependencies | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy the application code to the working directory | ||
COPY . . | ||
|
||
# Expose the port on which the FastAPI application will run | ||
EXPOSE 8000 | ||
|
||
# Set the command to run the application | ||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] | ||
``` | ||
|
||
To use this Dockerfile, follow these steps: | ||
|
||
1. Create a new directory for your project and navigate to it in your terminal. | ||
|
||
2. Create a file named `requirements.txt` in the project directory and add the following dependencies: | ||
|
||
``` | ||
fastapi | ||
uvicorn | ||
minio | ||
requests | ||
unstructured | ||
docker | ||
openai | ||
langchain | ||
weaviate-client | ||
``` | ||
|
||
3. Create a file named `app.py` in the project directory and copy the refined script code that I provided earlier into it. | ||
|
||
4. Create a file named `Dockerfile` (without any extension) in the project directory and copy the Dockerfile code provided above into it. | ||
|
||
5. Open a terminal in the project directory and build the Docker image by running the following command: | ||
|
||
```bash | ||
docker build -t cdaprod/cda-minio-control . | ||
``` | ||
|
||
6. Once the image is built, you can run the container using the following command: | ||
|
||
```bash | ||
docker run -p 8000:8000 --name cda-minio-control \ | ||
-e OPENAI_API_KEY=<your-openai-api-key> \ | ||
-e MINIO_ENDPOINT=<your-minio-endpoint> \ | ||
-e MINIO_ACCESS_KEY=<your-minio-access-key> \ | ||
-e MINIO_SECRET_KEY=<your-minio-secret-key> \ | ||
cdaprod/cda-minio-control | ||
``` | ||
|
||
Make sure to replace `<your-openai-api-key>`, `<your-minio-endpoint>`, `<your-minio-access-key>`, and `<your-minio-secret-key>` with your actual values. | ||
|
||
7. The application should now be running inside the container. You can access the FastAPI endpoints using `http://localhost:8000` in your browser or API client. | ||
|
||
To push the Docker image to Docker Hub, follow these steps: | ||
|
||
1. Log in to Docker Hub using the `docker login` command in your terminal. | ||
|
||
2. Push the image to Docker Hub using the following command: | ||
|
||
```bash | ||
docker push cdaprod/cda-minio-control | ||
``` | ||
|
||
Make sure you have the necessary permissions to push to the `cdaprod` namespace on Docker Hub. | ||
|
||
That's it! Your application is now containerized and pushed to Docker Hub. You can easily deploy and run it on any system that has Docker installed. | ||
|
||
Let me know if you have any further questions! |