Skip to content
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
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ vars.REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
DATABASE_URL: 'file:./dev.db'
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"
6 changes: 5 additions & 1 deletion .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ vars.REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
DATABASE_URL: 'file:./dev.db'
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"
8 changes: 4 additions & 4 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -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 /
Expand All @@ -27,4 +27,4 @@ COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 3000
ENTRYPOINT ["/entrypoint.sh"]
CMD ["node", "./server/index.mjs"]
CMD ["node", "./server/index.mjs"]
1 change: 1 addition & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
19 changes: 14 additions & 5 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -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'
}
})

Expand Down
Loading