Skip to content

Commit

Permalink
changed to cloud run
Browse files Browse the repository at this point in the history
  • Loading branch information
anusha267 committed Nov 3, 2024
1 parent 357b523 commit 05cf3f7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .env.prod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PORT=3000
PORT=8080
DATABASE_URL=${DATABASE_URL_PROD}
JWT_SECRET=${JWT_SECRET_PROD}
2 changes: 1 addition & 1 deletion .env.uat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PORT=3000
PORT=8080
DATABASE_URL=${DATABASE_URL_UAT}
JWT_SECRET=${JWT_SECRET_UAT}
29 changes: 18 additions & 11 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
name: Deploy to Cloud Run on merge
on:
push:
branches:
- main

jobs:
build_and_deploy:
runs-on: ubuntu-latest
Expand All @@ -17,16 +15,25 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "23"

- name: Install dependencies
run: npm install

- name: Run build
run: npm run build:prod

- name: Firebase Deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_BOOKENZY_F32CD }}
channelId: live
projectId: bookenzy-f32cd
# - name: Setup Google Cloud SDK
# uses: google-github-actions/setup-gcloud@v4
# with:
# service_account_key: ${{ secrets.GCP_SA_KEY }}
# project_id: ${{ secrets.GCP_PROJECT_ID }}
# export_default_credentials: true

# - name: Build and Deploy to Cloud Run
# run: |
# gcloud builds submit --tag gcr.io/${{ secrets.GCP_PROJECT_ID }}/your-image-name
# gcloud run deploy your-service-name \
# --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/your-image-name \
# --platform managed \
# --region your-region \
# --allow-unauthenticated
12 changes: 6 additions & 6 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
- name: Run build
run: npm run build:prod

- name: Firebase Deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_BOOKENZY_F32CD }}
projectId: bookenzy-f32cd
# - name: Firebase Deploy
# uses: FirebaseExtended/action-hosting-deploy@v0
# with:
# repoToken: ${{ secrets.GITHUB_TOKEN }}
# firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_BOOKENZY_F32CD }}
# projectId: bookenzy-f32cd
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js image from Docker Hub.
FROM node:18

# Set the working directory inside the container.
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the container.
COPY package*.json ./

# Install application dependencies.
RUN npm install

# Copy the rest of your application code to the container.
COPY . .

# Expose the port that your application will run on.
EXPOSE 8080

# Command to run your application.
CMD [ "npm", "start" ]
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ app.use("/v1/books", bookRoutes);
app.use("/v1/logs", logRoutes);

// Start the server
const PORT = process.env.PORT || 3000;
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});

0 comments on commit 05cf3f7

Please sign in to comment.