-
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.
* Added docker setup #49 * Added new pipeline for GCP deploy #49 * Optimized dependencies for containerization #49 * Implemented waitress to host production WSGI HTTP server #49 * Update pipeline to move away from google cloud build #49 * Remove aws files #49 * Test fix attempt #49
- Loading branch information
Showing
14 changed files
with
442 additions
and
938 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,13 @@ | ||
.github | ||
.git | ||
.gitignore | ||
.dockerignore | ||
Dockerfile | ||
.ruff_cache | ||
.venv | ||
aws | ||
tests | ||
.env | ||
.pre-commit-config.yaml | ||
Makefile | ||
poetry.toml |
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,63 +1,26 @@ | ||
name: Deploy Pipeline | ||
on: [workflow_dispatch] | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
env: | ||
REGION: us-central1 | ||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
- name: Authenticate to Google Cloud | ||
uses: "google-github-actions/auth@v2" | ||
with: | ||
python-version: "3.12" | ||
cache: "pip" | ||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
- name: Display AWS CLI version | ||
run: aws --version | ||
- name: Restore cached .venv | ||
uses: actions/cache/restore@v4 | ||
id: cache-venv | ||
with: | ||
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }} | ||
path: .venv | ||
- name: Setup environment | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry config --list | ||
- name: Install dependencies | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
run: poetry install --no-interaction --no-root | ||
- name: Cache .venv | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }} | ||
path: .venv | ||
- name: Create .env | ||
uses: SpicyPizza/create-envfile@v2.0 | ||
with: | ||
envkey_DEV: "dev" | ||
envkey_MONGO_TOKEN: ${{ secrets.MONGO_TOKEN }} | ||
file_name: .env | ||
- name: AWS Setup | ||
run: | | ||
mkdir -p ~/.aws | ||
cat > ~/.aws/config << EOF | ||
[profile dev] | ||
role_arn = ${{ secrets.LAMBDA_ARN }} | ||
source_profile = default | ||
EOF | ||
cat > ~/.aws/credentials << EOF | ||
[default] | ||
aws_access_key_id = ${{ secrets.DEV_ID }} | ||
aws_secret_access_key = ${{ secrets.DEV_KEY }} | ||
EOF | ||
- name: Build Lambda code | ||
run: poetry run python aws/build_lambda_code.py | ||
- name: Deploy stack | ||
shell: bash | ||
run: | | ||
chmod +x ./aws/deploy.sh | ||
./aws/deploy.sh ${{ secrets.MONGO_TOKEN }} | ||
wait | ||
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" | ||
- name: Configure Docker | ||
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | ||
- name: Build Docker Container | ||
run: docker build . -t ${{ secrets.CONTAINER_IMAGE_URL }} | ||
- name: Push Docker Container to Google Cloud | ||
run: docker push ${{ secrets.CONTAINER_IMAGE_URL }} | ||
- name: Deploy Container to Google Cloud Run | ||
run: gcloud run deploy imaginate-api --image ${{ secrets.CONTAINER_IMAGE_URL }} --region ${{ env.REGION }} |
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,8 @@ | ||
FROM python:3.12-slim | ||
RUN pip install poetry==1.8.4 | ||
WORKDIR /api | ||
COPY . . | ||
RUN poetry install --without dev --sync | ||
CMD ["poetry","run","python", "imaginate_api/app.py"] | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.