diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d7b74be --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +Dockerfile +.dockerignore +.git/ +.env +node_modules/ +.nuxt/ +.output/ +server/utils/generated/ +README.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d11f459..1d95529 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,31 +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 ECS service will update now" diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index 2789402..3e7175f 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -5,39 +5,34 @@ on: branches: - stage -env: - DATABASE_URL:"file:./prisma/dev.db" - jobs: build: permissions: id-token: write # This is required for requesting the JWT - runs-on: ubuntu-latest - + 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: 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: arn:aws:iam::654654236858:role/GithubActions + 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: abide-connect - IMAGE_TAG: ${{ github.sha}}-stage - DATABASE_URL: "file:./prisma/dev.db" + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: ${{ vars.REPOSITORY }} + IMAGE_TAG: ${{ github.sha }} + DATABASE_URL: "file:./dev.db" + CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }} + SERVICE_NAME: ${{ vars.REPOSITORY }}-stage-service run: | - docker buildx build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG . - docker buildx build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:stage . + 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 ECS service will update now" diff --git a/.gitignore b/.gitignore index e3e2872..37f18f7 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,6 @@ logs # Prisma related files prisma/dev.db -prisma/migrations -.vscode/* +.vscode/* server/utils/generated/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3b369e3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +# Build container +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 PATH="$PNPM_HOME:$PATH" +RUN npm i -g pnpm + +RUN pnpm i --frozen-lockfile + +COPY . ./ +RUN pnpm prisma generate +RUN pnpm run build + +# Deployment container +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 /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 + +# 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"] +CMD ["node", "./server/index.mjs"] diff --git a/README.md b/README.md index 6b8ca7c..bc5d90c 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ Post-Signup Volunteer Dashboard Admin Dashboard (Admin only) - Overview Panel - - Event management - Training Certificate approval - Volunteer hour log approval + - Donation fund creation Event Management - Add Event (options: volunteer-only, public, internal) @@ -86,7 +86,7 @@ Next, make sure to create a `.env` file based on the `.env.example` file and fil Then, initialize prisma client. ```bash -pnpx prisma generate +pnpm prisma generate ``` The generated client will be placed in `/server/utils/generated/prisma`. @@ -94,8 +94,8 @@ The generated client will be placed in `/server/utils/generated/prisma`. Next, migrate and seed the database. ```bash -pnpx prisma migrate dev -pnpx prisma db seed +pnpm prisma migrate dev +pnpm prisma db seed ``` You are now ready to use/deploy the app! @@ -121,8 +121,8 @@ After performing database operations, it may be good to reset the database to en In order to achieve this, run the following commands: ```bash -pnpx prisma migrate reset -pnpx prisma db seed +pnpm prisma migrate reset +pnpm prisma db seed ``` ### Production @@ -140,4 +140,4 @@ pnpm run build ## Deploying to Production There is currently a Github Actions flow setup such that for each commit to main, a new build is created and dockerized. -We can then manually deploy to the NPTS EC2 instances for prod and staging that are currently set up. \ No newline at end of file +This then gets automatically deployed to the NPTS ECS cluster. diff --git a/app/app.config.ts b/app/app.config.ts index 62d3d39..5dfc651 100644 --- a/app/app.config.ts +++ b/app/app.config.ts @@ -1 +1 @@ -export default defineAppConfig({}); \ No newline at end of file +export default defineAppConfig({}) diff --git a/app/app.vue b/app/app.vue index 2bc0562..0ecc1ed 100644 --- a/app/app.vue +++ b/app/app.vue @@ -1,7 +1,17 @@ \ No newline at end of file + diff --git a/app/components/event/Editor.vue b/app/components/event/Editor.vue index 3128815..1058cdd 100644 --- a/app/components/event/Editor.vue +++ b/app/components/event/Editor.vue @@ -1,72 +1,153 @@ \ No newline at end of file + diff --git a/app/components/event/ImageUpload.vue b/app/components/event/ImageUpload.vue new file mode 100644 index 0000000..05b1a73 --- /dev/null +++ b/app/components/event/ImageUpload.vue @@ -0,0 +1,112 @@ + + + diff --git a/app/components/event/Modal.vue b/app/components/event/Modal.vue index 8db52bc..5d66dab 100644 --- a/app/components/event/Modal.vue +++ b/app/components/event/Modal.vue @@ -1,68 +1,45 @@ - \ No newline at end of file + diff --git a/app/components/event/RSVPModal.vue b/app/components/event/RSVPModal.vue new file mode 100644 index 0000000..002fe50 --- /dev/null +++ b/app/components/event/RSVPModal.vue @@ -0,0 +1,96 @@ + + + diff --git a/app/components/event/RSVPStats.vue b/app/components/event/RSVPStats.vue new file mode 100644 index 0000000..0bbbbf8 --- /dev/null +++ b/app/components/event/RSVPStats.vue @@ -0,0 +1,148 @@ + + + diff --git a/app/components/event/Tile.vue b/app/components/event/Tile.vue index 576600e..eb0b8e7 100644 --- a/app/components/event/Tile.vue +++ b/app/components/event/Tile.vue @@ -1,36 +1,66 @@ + \ No newline at end of file + diff --git a/app/components/map/Interactive.client.vue b/app/components/map/Interactive.client.vue index 7b1dbca..f2ae87d 100644 --- a/app/components/map/Interactive.client.vue +++ b/app/components/map/Interactive.client.vue @@ -4,19 +4,19 @@ :center="center" :zoom="zoom" :attribution-control="false" - > - + > + + /> diff --git a/app/components/nav/Bottom.vue b/app/components/nav/Bottom.vue index e4dab35..9cb1226 100644 --- a/app/components/nav/Bottom.vue +++ b/app/components/nav/Bottom.vue @@ -1,41 +1,42 @@ + diff --git a/app/components/nav/SecondaryTop.vue b/app/components/nav/SecondaryTop.vue index f36e207..fd60c29 100644 --- a/app/components/nav/SecondaryTop.vue +++ b/app/components/nav/SecondaryTop.vue @@ -3,21 +3,26 @@ const router = useRouter() diff --git a/app/layouts/default.vue b/app/layouts/default.vue index 3e9af13..d3f49d0 100644 --- a/app/layouts/default.vue +++ b/app/layouts/default.vue @@ -2,9 +2,9 @@ diff --git a/app/layouts/secondary.vue b/app/layouts/secondary.vue index 62c390b..eae5c8c 100644 --- a/app/layouts/secondary.vue +++ b/app/layouts/secondary.vue @@ -1,7 +1,7 @@ \ No newline at end of file +
+ + + +
+ diff --git a/app/lib/relativeFetch.ts b/app/lib/relativeFetch.ts index b6e556b..6eb5dfb 100644 --- a/app/lib/relativeFetch.ts +++ b/app/lib/relativeFetch.ts @@ -4,8 +4,9 @@ import { useFetch } from '#app' export const relativeFetch = ((url: string, opts?: any) => { try { if (url.startsWith('http')) url = new URL(url).pathname - } catch { + } + catch { // ignore invalid URLs } return useFetch(url, opts) -}) as any \ No newline at end of file +}) as any diff --git a/app/middleware/auth.ts b/app/middleware/auth.ts index 2997b5d..4aff9c2 100644 --- a/app/middleware/auth.ts +++ b/app/middleware/auth.ts @@ -4,16 +4,17 @@ export default defineNuxtRouteMiddleware(async (to) => { try { const data = await $fetch('/api/auth/get-session', { - cache: 'no-store', // ← forces fresh request every time + cache: 'no-store', // ← forces fresh request every time headers: { - 'Cache-Control': 'no-cache' - } + 'Cache-Control': 'no-cache', + }, }) - + if (!data?.session) { return navigateTo('/auth/login') } - } catch { + } + catch { return navigateTo('/auth/login') } -}) \ No newline at end of file +}) diff --git a/app/pages/admin/donations.vue b/app/pages/admin/donations.vue new file mode 100644 index 0000000..fac075c --- /dev/null +++ b/app/pages/admin/donations.vue @@ -0,0 +1,344 @@ + + + diff --git a/app/pages/admin/index.vue b/app/pages/admin/index.vue index df65126..5c63229 100644 --- a/app/pages/admin/index.vue +++ b/app/pages/admin/index.vue @@ -1,130 +1,143 @@ \ No newline at end of file +
+

+ {{ kpi.label }} +

+

+ {{ kpi.value }} +

+
+
+
+ + + +
+ +
+ +
+ + {{ feature.label }} + + + + {{ feature.description }} + +
+ + Manage → + +
+
+
+ + diff --git a/app/pages/admin/volunteer-logs/index.vue b/app/pages/admin/volunteer-logs/index.vue index b1d7fa4..16a1587 100644 --- a/app/pages/admin/volunteer-logs/index.vue +++ b/app/pages/admin/volunteer-logs/index.vue @@ -1,218 +1,340 @@