Skip to content

Commit

Permalink
Feature/build (#2)
Browse files Browse the repository at this point in the history
* change image

* update image definitions

* match container names

* test frontend

* update build

* install dependencies

* update build

* update build definitions

* update build

* Switch parser

* switch LLM used
  • Loading branch information
k-ong-ipa authored Feb 26, 2025
1 parent 5f9b69d commit d256014
Show file tree
Hide file tree
Showing 16 changed files with 4,255 additions and 3,447 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# === LLM ===
ANTHROPIC_API_KEY=""

# AWS Bedrock settings
AWS_BEDROCK_MODEL_ID=

# Legacy Azure OpenAI settings (kept for backward compatibility)
AZURE_OPENAI_KEY=
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_API_VERSION=2024-02-01
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Put action within a raw block so that the curly bracket expressions aren't picked up by the cookiecutter
#
#
name: Checks

env:
Expand Down Expand Up @@ -32,4 +32,3 @@ jobs:
run: |
poetry run ruff format . --check
poetry run ruff check .
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
13 changes: 6 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
name: Check for files larger than 5 MB
args: [ "--maxkb=5120" ]
args: ["--maxkb=5120"]

- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
- id: detect-secrets
exclude: (poetry.lock|frontend/pnpm-lock.yaml|.env.example|.env.test|^.github/workflows/|.cruft.json|alembic/)

- repo: local
hooks:
- id: detect-ip
- id: detect-ip
name: Detect IP addresses
entry: '^(?!0\.0\.0\.0$)(?!127\.0\.0\.1$)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
language: pygrep
Expand All @@ -26,12 +25,12 @@ repos:

- repo: local
hooks:
- id: detect-aws-account
- id: detect-aws-account
name: Detect AWS account numbers
language: pygrep
entry: ':\d{12}:'

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
- id: nbstripout
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def upgrade() -> None:

def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("user", sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=False))
op.add_column("user", sa.Column("username", sa.VARCHAR(), autoincrement=False, nullable=False))
op.add_column(
"user", sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=False)
)
op.add_column(
"user", sa.Column("username", sa.VARCHAR(), autoincrement=False, nullable=False)
)
op.drop_column("user", "email")
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Start with the official Python base image
FROM python:3.11-slim
FROM public.ecr.aws/docker/library/python:3.11-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
Expand Down
30 changes: 15 additions & 15 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ phases:
pre_build:
commands:
- echo "Logging in to Amazon ECR"
- aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin $ECR_DOCKER_REGISTRY
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com

build:
commands:
- echo "Building a Docker image for backend"
- docker build -t $ECR_REPOSITORY_BACKEND_URL -f backend/Dockerfile .
- echo "SKIP Building a Docker image for backend"
# - docker build -t $ECR_REPOSITORY_BACKEND_URL:latest -f backend/Dockerfile .
- echo "Building a Docker image for frontend"
- docker build -t $ECR_REPOSITORY_FRONTEND_URL -f frontend/Dockerfile .
- docker build -t $ECR_REPOSITORY_FRONTEND_URL:latest -f frontend/Dockerfile frontend

post_build:
commands:
- echo "Build completed on `date`"
- echo "Pushing the backend Docker images..."
- docker push $ECR_REPOSITORY_BACKEND_URL
- echo "Pushing the frontend Docker images..."
- docker push $ECR_REPOSITORY_FRONTEND_URL
- echo "Writing image definitions files..."
- printf '[{"name":"scout-backend","imageUri":"%s:latest"}]' $ECR_REPOSITORY_BACKEND_URL > backend_imagedefinitions.json
- printf '[{"name":"scout-fronted","imageUri":"%s:latest"}]' $ECR_REPOSITORY_FRONTEND_URL > frontend_imagedefinitions.json

- echo "SKIP Pushing the backend Docker image..."
# - docker push $ECR_REPOSITORY_BACKEND_URL:latest
- echo "Pushing the frontend Docker image..."
- docker push $ECR_REPOSITORY_FRONTEND_URL:latest
- echo "Writing image definitions file for ECS deployment..."
# - printf '[{"name":"backend","imageUri":"%s"}]' $ECR_REPOSITORY_BACKEND_URL:latest > imagedefinitions.json
- printf '[{"name":"frontend","imageUri":"%s"}]' $ECR_REPOSITORY_FRONTEND_URL:latest >> imagedefinitions.json
- echo Contents of imagedefinitions.json:
- cat imagedefinitions.json
artifacts:
files:
- backend_imagedefinitions.json
- frontend_imagedefinitions.json
- imagedefinitions.json
name: image_definitions

cache:
paths:
- /root/.cache/pip
- /root/.npm
- /root/.npm
24 changes: 14 additions & 10 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# Use an official Node.js runtime as a parent image
FROM node:20
FROM node:20.13.1-alpine@sha256:a7b980c958bfe4d84ee9263badd95a40c8bb50ad5afdb87902c187fefaef0e24 AS builder

# Set the working directory in the container
WORKDIR /app

# Copy the application code to the working directory
COPY frontend/ ./
COPY package.json package-lock.json ./
RUN npm install

# Install the application dependencies
RUN npm ci
COPY . ./
RUN npm run build

FROM builder AS runner

WORKDIR /app

COPY --from=builder /app/package.json /app/package-lock.json ./
COPY --from=builder /app/.next /app/.next
COPY --from=builder /app/public /app/public

# Expose the port the app runs on
EXPOSE 3000

# Run the development server
CMD ["npm", "run", "dev"]
CMD ["npm", "start"]
Loading

0 comments on commit d256014

Please sign in to comment.