diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..047eb2c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,26 @@ +# Include files that you wouldn't want included in your container + +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.vs +**/.vscode +**/.next +**/.cache +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/build +**/dist +LICENSE +README.md +**/public/__env.js diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..fc84947 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +# These owners will be the default owners for everything in the repo. +* @muriukialex @effiecancode @Topsideboss2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..35c1043 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,5 @@ +## Contributing Guide + +- Fork the application, add your changes and make a [PR/MR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) + +Contributions are highly welcome! \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..57ce3a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM node:18-alpine as base + +WORKDIR /app + +COPY package*.json ./ + +FROM base as builder + +WORKDIR /app + +COPY . . +# Install project dependencies +RUN npm install +RUN npm run build + +FROM base as production + +WORKDIR /app + +ENV NODE_ENV=production + +# Install only production dependencies +RUN npm ci --omit=dev + +RUN addgroup -g 1001 -S nodejs +RUN adduser -S nextjs -u 1001 + +USER nextjs + +# Copy necessary files from builder stage +COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next +COPY --from=builder --chown=nextjs:nodejs /app/next.config.mjs ./ +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/public ./public +COPY --from=builder /app/.env.local ./.env +COPY --from=builder /app/entrypoint.sh ./entrypoint.sh + +EXPOSE 3000 + +# specifies the command to run when the Docker image is started +ENTRYPOINT ["./entrypoint.sh"] + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ad05635 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +start-app: + docker-compose up + +tear-app: + docker-compose down --rmi all + +# Phony targets to avoid conflicts with file names +.PHONY: start-app tear-app diff --git a/README.md b/README.md index c403366..35920d9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,47 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). +# Keep Track of AWS r/Start Labs + +- This application is designed to help AWS r/Start students to keep track of their AWS r/Start Labs. + +## Overview + +### Sign In +Sign In with Google + +![sign-in(light)](https://github.com/muriukialex/aws-rstart-labs/assets/51236424/d185ecd5-0b85-47e4-8a19-8f8d06cd2d1a) + +### Track Labs as Completed +Light Theme Option + +![Screenshot 2024-02-24 192722](https://github.com/muriukialex/aws-rstart-labs/assets/51236424/ddda199b-b43d-42b6-b6ff-e230567c76ac) + +Dark Theme Option + + +![Screenshot 2024-02-24 192910](https://github.com/muriukialex/aws-rstart-labs/assets/51236424/c54117b1-8f43-44ba-93ae-918200c8888a) + +### Update Lab Completed Status + +![Screenshot 2024-02-24 193020](https://github.com/muriukialex/aws-rstart-labs/assets/51236424/e14890c5-acea-41f4-ae2f-92ceb8a68d1a) ## Getting Started -First, run the development server: +1. Clone the project + ```bash + git clone https://github.com/muriukialex/aws-rstart-labs.git +``` + +2. Install dependencies +```bash +npm install +``` + +3. Update your `.env.local` file with your enviroment variables which also includes a [MONGODB_URI](https://www.mongodb.com/basics/mongodb-connection-string#:~:text=How%20to%20get%20your%20MongoDB,connection%20string%20for%20your%20cluster.) +```bash +cp .env.example .env.local +``` +NB: Ensure you update your environent variables before starting the server + +3. Run the development server: ```bash npm run dev @@ -16,21 +55,19 @@ bun dev Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. - -## Learn More +If you are using Docker: +Ensure you have [make](https://www.gnu.org/software/make/manual/make.html) installed `make --version` -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! +- Build and run the Docker container +```bash +make start-app +``` -## Deploy on Vercel +- Tear down the Docker container +```bash +make tear-app +``` -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. +## Contributing +- See [CONTRIBUTING.md](https://github.com/muriukialex/aws-rstart-labs/main/CONTRIBUTING.md) instructions on how to contribute. -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9c3e176 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: "3" +services: + aws-rstart-labs: + build: . + ports: + - "3000:3000" diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..598d887 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# run npm run start through pm2 +pm2 start npm -- run start + +# show logs +pm2 logs diff --git a/hooks/useUserLabsData.tsx b/hooks/useUserLabsData.tsx index 3b5d009..1581796 100644 --- a/hooks/useUserLabsData.tsx +++ b/hooks/useUserLabsData.tsx @@ -17,16 +17,14 @@ const useUserLabsData = ({ email }: { email?: string | null }) => { try { const response = await getLabs({ email }) const responseData = response.data + setError(null) // update the error value to null setData(responseData) - setIsLoading({ - status: "idle", - }) } catch (error) { const errorResponse = error as ErrorResponse if (errorResponse) { setError(errorResponse) } - + } finally { setIsLoading({ status: "idle", })