Skip to content

Commit

Permalink
feat: final MVP & Merge From development Branch to Staging (#32) (#33)
Browse files Browse the repository at this point in the history
* feat(docs): change server information on OpenAPI Swagger

* feat(deployment): add distroless image on Dockerfile

* feat(api): add endpoint GET /roles/{roleId}

* feat(api): add schema folder

* feat(api): finish endpoint role

* feat(db): add log on PrismaClient

* feat(api): add query param on GET /roles?name=

* feat(db): add phoneNumber field on model User

* feat(db): add phoneNumber field on model User

* feat(db): add seeding for table user

* feat(api): change exception parameter position message and res

* feat(docs): add query param name at /roles OpenAPI Swagger

* feat(docs): add 409 Conflict at /auth/signup and change 500 error example OpenAPI Swagger

* feat(api): add endpoint POST /auth/signup

* feat(api): add endpoint POST /auth/signin

* feat(api): add endpoint GET /roken/refresh and middleware for verify accessToken

* feat(api): add endpoint DELETE /auth/signout

* feat(docs): add 401 and 403 at /auth/signout example OpenAPI Swagger

* feat(api): remove middleware on GET /token/refresh

* feat(api): add endpoint GET /users

* feat(api): add endpoint GET /users/:userId

* feat(deployment): remove distroless image on Dockerfile

* feat(deployment): update Dockerfile

* feat(api): add endpoint PUT /users/:userId

* feat(docs): add password schema to PATCH /users/{userId}

* feat(api): add endpoint PATCH /users/:userId

* feat(api): add endpoint DELETE /users/:userId

* feat(db): add works and educations seeder

* feat(api): add endpoint GET, POST /works & GET, PUT, DELETE /works/:workId

* feat(api): add endpoint GET, POST /educations & GET, PUT, DELETE /educations/:educationId

* feat(assets): add default male and female avatar

* feat(auth): add serviceaccount gcp for upload avatar to bucket

* feat(env): add GCLOUD_BUCKET_NAME for google cloud storage bucket to store avatar user

* feat(env): add GCLOUD_PROJECT_ID

* feat(dependency): add dateformat

* feat(docs): add query param name at /works and /educations OpenAPI Swagger

* feat(dependency): add uuid

* feat(migration): add nullable user profile

* feat(migration): allow nullable user profile

* feat(migration): add cascade delete on profile

* feat(api): add default avatar user based on the gender when signup

* feat(schema): add nullable on model Profile

* feat(util): add bucket utility

* feat(middleware): add images middleware, handle with multer

* feat(api): add endpoint PUT /users/:userId/profile/avatar

* feat(dependency): remove uuid

* feat(dependency): remove uuid

* feat(api): change url with utility function

* feat(docs): add PUT /users/:userId/profile/avatar to OpenAPI Swagger

* feat(deployment): update workflow yml file

* feat(deployment): add regex to add double quote to get valid json format on serviceaccount

* feat(deployment): remove regex

* feat(util): remove serviceaccount on bucket google cloud storage configuration

* feat(api): add endpoint GET /users/:userId/profile

* feat(api): add endpoint PATCH /users/:userId/profile

* feat(schema): add nullable on profile

* feat(docs): remove POST & PUT /users/:userId/profile

* feat(api): add endpoint DELETE /users/:userId/profile

* feat(api): throw error to console

* feat(api): add url encoded

* feat(api): add parseInt on age request body

* feat(api): update JWT accessToken expired

* docs(chats): add chats documentation to swagger

* docs(chats): change chat doc follow spec

* feat(chats): implement restfull api for room chats

* feat(chat-ai): implement forward request for chat ai service

* ci: add ml url env variable to github workflow

* feat(api): update JWT accessToken expired

* feat(api): add profile data on users endpoint

* feat(docs): update README

* feat(docs): update README

* feat(docs): update response example

* feat(api): add response id with specify field, e.g. userId, roleId, workId, educationId

* feat(api): add response id with specify field, e.g. userId, roleId, workId, educationId

* feat(docs): update response example and schema

* feat(db): update seeder

* feat(docs): update README

* feat(setup): update Dockerfile

* feat(setup): update Dockerfile

* feat(setup): update Dockerfile

* feat(setup): update Dockerfile

* feat(api): add condition on user age update data partial

* feat(api): add res to second parameter

* feat(testing): add postman collection and environment

* feat(docs): update README

* feat(db): update seeder

* feat(api): update query users

* feat(api): update query users

* feat(db): update schema & seeder

* feat(db): update schema

* feat(api): update schema validation, controller, and repository for model user profile

* feat(db): update schema formatting decimal

* feat(db): update seeder

* feat(docs): update response example and schema

* feat(api): update JWT accessToken expired

* feat(api): add profile data on users endpoint

* feat(docs): update README

* feat(docs): update README

* feat(docs): update response example

* feat(api): add response id with specify field, e.g. userId, roleId, workId, educationId

* feat(api): add response id with specify field, e.g. userId, roleId, workId, educationId

* feat(docs): update response example and schema

* feat(db): update seeder

* feat(docs): update README

* feat(setup): update Dockerfile

* feat(setup): update Dockerfile

* feat(setup): update Dockerfile

* feat(setup): update Dockerfile

* feat(api): add condition on user age update data partial

* feat(api): add res to second parameter

* feat(testing): add postman collection and environment

* feat(docs): update README

* feat(db): update seeder

* feat(api): update query users

* feat(api): update query users

* feat(db): update schema & seeder

* feat(db): update schema

* feat(api): update schema validation, controller, and repository for model user profile

* feat(db): update schema formatting decimal

* feat(db): update seeder

* feat(docs): update response example and schema

* feat(chat-ai): change ai spec for generative ai n add some body from user profile to suggest ai

* fix(chat-ai): change total question input to string parse on be

---------

Co-authored-by: nurhudajoantama <[email protected]>
Co-authored-by: Nurhuda Joantama Putra <[email protected]>
  • Loading branch information
3 people authored Jun 18, 2024
1 parent 69ce8f5 commit 0e1bf6c
Show file tree
Hide file tree
Showing 76 changed files with 7,414 additions and 334 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ EXPRESS_PORT=8080

JWT_ACCESS_TOKEN_SECRET='<YOUR_RANDOM_STRING_FOR_JWT_ACCESS_TOKEN_SECRET>' # The JWT secret can be generate with this command `npm run generate:secret:jwt`
JWT_REFRESH_TOKEN_SECRET='<YOUR_RANDOM_STRING_FOR_JWT_REFRESH_TOKEN_SECRET>'

GCLOUD_PROJECT_ID="your-gcloud-project-id"
GCLOUD_BUCKET_NAME="your-bucket-name"

GENERATIVE_AI_SERVICE_URL="<YOUR_GENERATIVE_AI_SERVICE_URL>"
SUGGESTION_AI_SERVICE_URL="<YOUR_SUGGESTION_AI_SERVICE_URL>"
16 changes: 16 additions & 0 deletions .github/workflows/google-cloudrun-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ jobs:
echo "EXPRESS_PORT=${{ secrets.EXPRESS_PORT }}" >> .env.production
echo "JWT_ACCESS_TOKEN_SECRET=${{ secrets.JWT_ACCESS_TOKEN_SECRET }}" >> .env.production
echo "JWT_REFRESH_TOKEN_SECRET=${{ secrets.JWT_REFRESH_TOKEN_SECRET }}" >> .env.production
echo "GCLOUD_PROJECT_ID=${{ secrets.GCLOUD_PROJECT_ID }}" >> .env.production
echo "GCLOUD_BUCKET_NAME=${{ secrets.GCLOUD_BUCKET_NAME }}" >> .env.production
echo "GENERATIVE_AI_SERVICE_URL=${{ secrets.GENERATIVE_AI_SERVICE_URL }}" >> .env.production
echo "SUGGESTION_AI_SERVICE_URL=${{ secrets.SUGGESTION_AI_SERVICE_URL }}" >> .env.production
elif [[ "${GITHUB_REF##*/}" == "staging" ]]; then
echo "NODE_ENV=staging" >> $GITHUB_ENV
echo "DOCKER_TAG=staging-${{ github.sha }}" >> $GITHUB_ENV
Expand All @@ -95,6 +99,10 @@ jobs:
echo "EXPRESS_PORT=${{ secrets.EXPRESS_PORT }}" >> .env.staging
echo "JWT_ACCESS_TOKEN_SECRET=${{ secrets.JWT_ACCESS_TOKEN_SECRET }}" >> .env.staging
echo "JWT_REFRESH_TOKEN_SECRET=${{ secrets.JWT_REFRESH_TOKEN_SECRET }}" >> .env.staging
echo "GCLOUD_PROJECT_ID=${{ secrets.GCLOUD_PROJECT_ID }}" >> .env.staging
echo "GCLOUD_BUCKET_NAME=${{ secrets.GCLOUD_BUCKET_NAME }}" >> .env.staging
echo "GENERATIVE_AI_SERVICE_URL=${{ secrets.GENERATIVE_AI_SERVICE_URL }}" >> .env.staging
echo "SUGGESTION_AI_SERVICE_URL=${{ secrets.SUGGESTION_AI_SERVICE_URL }}" >> .env.staging
elif [[ "${GITHUB_REF##*/}" == "feat/setup-node" ]]; then
echo "NODE_ENV=dev" >> $GITHUB_ENV
echo "DOCKER_TAG=dev-${{ github.sha }}" >> $GITHUB_ENV
Expand All @@ -104,6 +112,10 @@ jobs:
echo "EXPRESS_PORT=${{ secrets.EXPRESS_PORT }}" >> .env.dev
echo "JWT_ACCESS_TOKEN_SECRET=${{ secrets.JWT_ACCESS_TOKEN_SECRET }}" >> .env.dev
echo "JWT_REFRESH_TOKEN_SECRET=${{ secrets.JWT_REFRESH_TOKEN_SECRET }}" >> .env.dev
echo "GCLOUD_PROJECT_ID=${{ secrets.GCLOUD_PROJECT_ID }}" >> .env.dev
echo "GCLOUD_BUCKET_NAME=${{ secrets.GCLOUD_BUCKET_NAME }}" >> .env.dev
echo "GENERATIVE_AI_SERVICE_URL=${{ secrets.GENERATIVE_AI_SERVICE_URL }}" >> .env.dev
echo "SUGGESTION_AI_SERVICE_URL=${{ secrets.SUGGESTION_AI_SERVICE_URL }}" >> .env.dev
else
echo "NODE_ENV=dev" >> $GITHUB_ENV
echo "DOCKER_TAG=dev-${{ github.sha }}" >> $GITHUB_ENV
Expand All @@ -113,6 +125,10 @@ jobs:
echo "EXPRESS_PORT=${{ secrets.EXPRESS_PORT }}" >> .env.dev
echo "JWT_ACCESS_TOKEN_SECRET=${{ secrets.JWT_ACCESS_TOKEN_SECRET }}" >> .env.dev
echo "JWT_REFRESH_TOKEN_SECRET=${{ secrets.JWT_REFRESH_TOKEN_SECRET }}" >> .env.dev
echo "GCLOUD_PROJECT_ID=${{ secrets.GCLOUD_PROJECT_ID }}" >> .env.dev
echo "GCLOUD_BUCKET_NAME=${{ secrets.GCLOUD_BUCKET_NAME }}" >> .env.dev
echo "GENERATIVE_AI_SERVICE_URL=${{ secrets.GENERATIVE_AI_SERVICE_URL }}" >> .env.dev
echo "SUGGESTION_AI_SERVICE_URL=${{ secrets.SUGGESTION_AI_SERVICE_URL }}" >> .env.dev
fi
- name: Clear Docker cache
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# gcp files
serviceaccount.json
39 changes: 34 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:20
# Stage 1: Build stage
FROM node:20 AS build

# Define build argument
ARG NODE_ENV
Expand All @@ -7,20 +8,48 @@ ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}
ENV PORT=8080

RUN mkdir -p /opt/app
# Install tzdata and set timezone
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
RUN ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && dpkg-reconfigure -f noninteractive tzdata

# Create app directory
WORKDIR /opt/app

COPY package*.json .
# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Generate Prisma client
RUN npm install -g dotenv-cli

RUN npx prisma generate
RUN dotenv -e .env.${NODE_ENV} -- npx prisma migrate deploy

# Stage 2: Run stage
# FROM gcr.io/distroless/nodejs20-debian12
# FROM node:20-slim

# Install tzdata and set timezone
# RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
# RUN ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && dpkg-reconfigure -f noninteractive tzdata

# Copy built files from the build stage
# COPY --from=build /opt/app /opt/app

# Set the working directory
# WORKDIR /opt/app

# Set environment variable for runtime
# ENV NODE_ENV=${NODE_ENV}
# ENV PORT=8080
ENV TZ=Asia/Jakarta

# Expose the port
EXPOSE 8080

CMD ["sh", "-c", "npm run start:${NODE_ENV}"]
# Run the application using shell to ensure the environment variable is picked up
CMD ["sh", "-c", "npm run start:${NODE_ENV}"]
Loading

0 comments on commit 0e1bf6c

Please sign in to comment.