Skip to content

Commit

Permalink
Merge pull request #1 from aafre/frontend
Browse files Browse the repository at this point in the history
Created a fully functional React Frontend
  • Loading branch information
aafre authored Dec 31, 2024
2 parents a4483d8 + 1964124 commit 2a15f0b
Show file tree
Hide file tree
Showing 54 changed files with 7,273 additions and 16 deletions.
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Ignore local environment and secrets
.env

# Ignore runtime artifacts
*.pdf
*.log
*.tmp

# Ignore IDE/Editor configuration and cache
.vscode/
.idea/
*.swp

# Ignore Python cache files and directories
__pycache__/
*.pyc
*.pyo
*.pyd

# Ignore node_modules, if applicable
node_modules/


.zip
64 changes: 64 additions & 0 deletions .github/workflows/docker-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build, Push, and Deploy to Cloud Run

on:
push:
branches:
- main
workflow_dispatch: # Allows manual trigger
inputs:
deploy:
description: "Deploy to Cloud Run after building?"
required: false
default: "false"

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# Checkout repository code
- name: Checkout
uses: actions/checkout@v4

# Authenticate with GCP
- name: Authenticate with GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Build and Push Docker Image with versioning
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ secrets.CR_NAME }}:latest
${{ secrets.CR_NAME }}:run-${{ github.run_number }}
${{ secrets.CR_NAME }}:sha-${{ github.sha }}
deploy:
needs: build-and-push
if: ${{ github.event.inputs.deploy == 'true' }}
runs-on: ubuntu-latest
steps:
# Authenticate with GCP
- name: Authenticate with GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

# Deploy to Cloud Run
- id: deploy-cloudrun
uses: google-github-actions/deploy-cloudrun@v2
with:
service: "resume-builder-app"
image: "${{ secrets.CR_NAME }}:latest"
region: "europe-west2"

# Output deployed URL
- name: Display Deployed URL
run: echo "Deployed to ${{ steps.deploy-cloudrun.outputs.url }}"
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,33 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


*.pdf
*.zip


# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
41 changes: 27 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
# Use the official Python image as a base
FROM python:3.9-slim
# Step 1: Build the React app
FROM node:22 AS react-build
WORKDIR /app/react
COPY resume-builder-ui/package*.json ./
RUN npm install
COPY resume-builder-ui/ ./
RUN npm run build

# Install wkhtmltopdf, xvfb, and other dependencies
RUN apt-get update && \
apt-get install -y \
wkhtmltopdf \
&& apt-get clean

# Set the working directory
# Step 2: Set up the Python (Flask) environment
FROM python:3.11-slim-bullseye AS flask
WORKDIR /app

# Copy requirements and install Python dependencies
# Install wkhtmltopdf and other dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
wkhtmltopdf \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code into the container
# Step 3: Copy the Flask app
COPY . .

# Command to run the Python script through xvfb
CMD ["python", "resume_generator.py"]
# Remove React code
RUN rm -rf /app/resume-builder-ui

# Copy React build output to Flask's static folder
COPY --from=react-build /app/react/dist/ /app/static/

# Expose the port that Cloud Run requires
EXPOSE 5000

# Command to run the app with gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
Loading

0 comments on commit 2a15f0b

Please sign in to comment.