Skip to content

Commit

Permalink
adding pull preview
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwan-samarasinghe committed Sep 7, 2024
1 parent 38cd3fd commit e7ab1e4
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .flaskenv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FLASK_APP=app.app.py
FLASK_APP=app.py
FLASK_ENV=development
FLASK_RUN_PORT=5000
31 changes: 31 additions & 0 deletions .github/workflows/pullpreview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: PullPreview
on:
pull_request:
types: [labeled, unlabeled, synchronize, closed, reopened]

jobs:
deploy:
permissions:
contents: read # to fetch code (actions/checkout)
deployments: write # to delete deployments
pull-requests: write # to remove labels
statuses: write # to create commit status
id-token: write # This is required for AWS credentials
name: deploy
runs-on: ubuntu-latest
timeout-minutes: 30
environment: ${{ inputs.environment || 'dev' }}
steps:
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy
role-session-name: FUNDING_SERVICE_DESIGN_FUND_APPLICATION_BUILDER_PULLPREVIEW
aws-region: eu-west-2
- uses: actions/checkout@v2
- uses: pullpreview/[email protected]
with:
compose_files: docker-compose.pullpreview.yml
ports: 8080/tcp
default_port: 8080
admins: gidsg
26 changes: 26 additions & 0 deletions Dockerfile.pullpreview
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Start with a Python base image
FROM python:3.10-slim
# Install PostgreSQL
RUN apt-get update && \
apt-get install -y postgresql postgresql-contrib
# Set environment variables for PostgreSQL
ENV POSTGRES_USER=postgres \
POSTGRES_PASSWORD=password \
POSTGRES_DB=fund_builder
# Expose the default PostgreSQL port
EXPOSE 5432
# Create a directory for the app
WORKDIR /app
# Copy application files
COPY . .
# Install Python dependencies into a virtual environment
RUN pip install --upgrade pip && pip install -r requirements-dev.txt
# Configure PostgreSQL (set up user, database, etc.)
RUN service postgresql start && \
su - postgres -c "psql -c \"ALTER USER ${POSTGRES_USER} WITH PASSWORD '${POSTGRES_PASSWORD}';\"" && \
su - postgres -c "psql -c \"CREATE DATABASE ${POSTGRES_DB};\"" && \
su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO ${POSTGRES_USER};\""
# Expose Flask app port
EXPOSE 8080
# Start PostgreSQL and the Flask app using the virtual environment
CMD service postgresql start && /bin/bash -c "python -m flask db upgrade && python -m debugpy --listen 0.0.0.0:5601 -m flask run --no-debugger --host 0.0.0.0 --port 8080"
20 changes: 20 additions & 0 deletions docker-compose.pullpreview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

services:
fab:
hostname: fab
build:
context: ../funding-service-design-fund-application-builder
dockerfile: Dockerfile.pullpreview
volumes: [
'../funding-service-design-fund-application-builder:/app',
'../funding-service-design-fund-application-builder/postgresql:/var/lib/postgresql/data',
]
ports:
- 5432:5432
- 8080:8080
environment:
- FORM_RUNNER_INTERNAL_HOST=http://localhost:3009
- FORM_RUNNER_EXTERNAL_HOST=http://localhost:3009
- DATABASE_URL=postgresql://postgres:password@localhost:5432/fund_builder
- FLASK_DEBUG=0
- FLASK_ENV=development

0 comments on commit e7ab1e4

Please sign in to comment.