From 52b5cf5fabfbd82a40b02209607b6617dc33f345 Mon Sep 17 00:00:00 2001 From: Aaron Menezes <123612000+aaron1857@users.noreply.github.com> Date: Fri, 24 Apr 2026 20:04:33 -0500 Subject: [PATCH 1/2] update workflows, dockerfile, seeding --- .github/workflows/main.yml | 10 +++++++--- .github/workflows/stage.yml | 10 +++++++--- dockerfile | 8 ++++---- entrypoint.sh | 1 + prisma/seed.ts | 19 ++++++++++++++----- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d11f459..2314e4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,10 +31,14 @@ jobs: - name: Build and Push Docker image env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry}} REPOSITORY: ${{ vars.REPOSITORY }} - IMAGE_TAG: ${{ github.sha }} - DATABASE_URL: 'file:./dev.db' + IMAGE_TAG: ${{ github.sha}} + DATABASE_URL: "file:./dev.db" + CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }} + SERVICE_NAME: ${{ vars.REPOSITORY }}-prod-service run: | docker build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG . docker build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:prod . + aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --force-new-deployment --output text --query "service.serviceName" >/dev/null + echo "The container will update now" diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index f2fc714..a959735 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -31,10 +31,14 @@ jobs: - name: Build and Push Docker image env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry}} REPOSITORY: ${{ vars.REPOSITORY }} - IMAGE_TAG: ${{ github.sha }} - DATABASE_URL: 'file:./dev.db' + IMAGE_TAG: ${{ github.sha}} + DATABASE_URL: "file:./dev.db" + CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }} + SERVICE_NAME: ${{ vars.REPOSITORY }}-stage-service run: | docker build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG . docker build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:stage . + aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --force-new-deployment --output text --query "service.serviceName" >/dev/null + echo "The container will update now" diff --git a/dockerfile b/dockerfile index 878295f..87f1728 100644 --- a/dockerfile +++ b/dockerfile @@ -1,17 +1,17 @@ # Build container -FROM node:22-alpine AS builder +FROM node:current-alpine AS builder COPY . ./ ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable +RUN npm i -g pnpm RUN pnpm i --frozen-lockfile RUN pnpm prisma generate RUN pnpm run build # Deployment container -FROM node:22-alpine AS deployment +FROM node:current-alpine AS deployment # Copy stuff from build container to ensure we have prisma and everything it needs COPY --from=builder /.output / @@ -27,4 +27,4 @@ COPY ./entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh EXPOSE 3000 ENTRYPOINT ["/entrypoint.sh"] -CMD ["node", "./server/index.mjs"] \ No newline at end of file +CMD ["node", "./server/index.mjs"] diff --git a/entrypoint.sh b/entrypoint.sh index c08aa88..e22eb69 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,7 @@ # Apply migrations and initialize migrations if it does not exist pnpm prisma generate pnpm prisma migrate deploy +pnpm prisma db seed # Run the CMD command from the dockerfile exec "$@" diff --git a/prisma/seed.ts b/prisma/seed.ts index 578dd88..5c1d02d 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,13 +1,22 @@ -import { prisma } from '../server/utils/prisma' +import { Param } from '@prisma/client/runtime/client' +import { PrismaClient } from "./generated/client" +import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3"; +import "dotenv/config"; +const connectionString = `${process.env.DATABASE_URL}`; + +const adapter = new PrismaBetterSqlite3({ url: connectionString }); +const prisma = new PrismaClient({ adapter }); async function main() { console.log('Start seeding...') // Create a User - const user1 = await prisma.user.create({ - data: { - name: "Sample Name", // modify this fit your needs - email: "email@example.com" + const user1 = await prisma.user.upsert({ + where: {email: 'seeded-user@email.com'}, + update: {}, + create: { + email: 'seeded-user@email.com', + name: 'Sample Seeded User' } }) From a673d2b77b61433803c9c8022606730d89d7201c Mon Sep 17 00:00:00 2001 From: Aaron Menezes <123612000+aaron1857@users.noreply.github.com> Date: Sat, 25 Apr 2026 08:08:01 -0500 Subject: [PATCH 2/2] fix spacing on workflows --- .github/workflows/main.yml | 4 ++-- .github/workflows/stage.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2314e4a..08f4593 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,9 +31,9 @@ jobs: - name: Build and Push Docker image env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry}} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} REPOSITORY: ${{ vars.REPOSITORY }} - IMAGE_TAG: ${{ github.sha}} + IMAGE_TAG: ${{ github.sha }} DATABASE_URL: "file:./dev.db" CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }} SERVICE_NAME: ${{ vars.REPOSITORY }}-prod-service diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index a959735..72a7398 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -31,9 +31,9 @@ jobs: - name: Build and Push Docker image env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry}} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} REPOSITORY: ${{ vars.REPOSITORY }} - IMAGE_TAG: ${{ github.sha}} + IMAGE_TAG: ${{ github.sha }} DATABASE_URL: "file:./dev.db" CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }} SERVICE_NAME: ${{ vars.REPOSITORY }}-stage-service