Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/49 migrate to gcp #50

Merged
merged 7 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .dockerignore
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
73 changes: 18 additions & 55 deletions .github/workflows/deploy.yml
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 }}
8 changes: 8 additions & 0 deletions Dockerfile
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"]


38 changes: 0 additions & 38 deletions aws/SETUP.md

This file was deleted.

95 changes: 0 additions & 95 deletions aws/billing.yml

This file was deleted.

113 changes: 0 additions & 113 deletions aws/build_lambda_code.py

This file was deleted.

35 changes: 0 additions & 35 deletions aws/deploy.sh

This file was deleted.

Loading
Loading