Skip to content
Open
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
.env
node_modules/
.nuxt/
.output/
README.md
dockerfile
.dockerignore
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,29 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ACTIONS_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: us-east-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and Push Docker image
env:
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"
echo "The ECS service will update now"
10 changes: 2 additions & 8 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,29 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ACTIONS_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: us-east-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and Push Docker image
env:
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"
echo "The ECS service will update now"
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

46 changes: 30 additions & 16 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
# Build container
FROM node:current-alpine AS builder
COPY . ./
FROM node:lts-alpine AS builder

# Use Workdir because things like tailwind will scan the entire current dir and can cause issues if it scans root
WORKDIR /app

COPY package.json ./
COPY pnpm-lock.yaml ./
COPY pnpm-workspace.yaml ./

ENV PNPM_HOME="/pnpm"
ENV PNPM_HOME="~/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm i -g pnpm

RUN pnpm i --frozen-lockfile
RUN pnpm prisma generate

COPY . ./
RUN pnpm run build
RUN pnpm prisma generate

# Deployment container
FROM node:current-alpine AS deployment

FROM node:lts-alpine AS deployment
WORKDIR /app
# Copy stuff from build container to ensure we have prisma and everything it needs
COPY --from=builder /.output /
COPY --from=builder /package.json /
COPY --from=builder /pnpm-lock.yaml /
COPY --from=builder /prisma.config.ts /
COPY --from=builder /prisma /prisma
COPY --from=builder /node_modules /node_modules
COPY --from=builder /app/.output ./
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/pnpm-workspace.yaml ./
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/prisma.config.ts ./
RUN npm i -g pnpm
COPY ./entrypoint.sh /entrypoint.sh

# Esnure we can actually run the entrypoint script
RUN chmod +x /entrypoint.sh
# Install Prisma without running any scripts to avoid running nuxt scripts
RUN pnpm i --dev --ignore-scripts --frozen-lockfile
# Run the build scripts needed for prisma to work (for migrations and seeding)
RUN pnpm rebuild esbuild better-sqlite3 @prisma/engines prisma
RUN pnpm prisma generate
COPY --from=builder /app/entrypoint.sh /entrypoint

# Ensure we can actually run the entrypoint script
RUN chmod +x /entrypoint
EXPOSE 3000
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint"]
CMD ["node", "./server/index.mjs"]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"dependencies": {
"@nuxt/image": "2.0.0",
"@nuxt/ui": "^4.4.0",
"@prisma/adapter-better-sqlite3": "^7.3.0",
"@prisma/client": "^7.3.0",
"@types/nodemailer": "^7.0.4",
"better-auth": "^1.4.7",
"dotenv": "^17.2.3",
Expand All @@ -25,6 +23,8 @@
"zod": "^4.2.1"
},
"devDependencies": {
"@prisma/adapter-better-sqlite3": "^7.3.0",
"@prisma/client": "^7.3.0",
"@types/better-sqlite3": "^7.6.13",
"concurrently": "^9.2.1",
"prettier": "3.7.4",
Expand Down
Loading