Skip to content

Commit

Permalink
build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SAINIAbhishek committed Oct 3, 2024
1 parent cb45e78 commit 3dabdbf
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 8 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,85 @@ jobs:
cache-path: 'node_modules'
cache-key-prefix: 'auth'
working-directory: './'

# Step: Build the project
build-development:
needs: [lint, format, dependencies-check]
runs-on: ubuntu-latest
environment: development
steps:
- name: Checkout Code
uses: actions/checkout@v3

# Restore Modules cache
- name: Restore Modules Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-auth-${{ hashFiles('package-lock.json') }}

- name: Build for development
run: npm run build
working-directory: ./
env:
PORT: ${{ vars.API_PORT }}
MONGO_URI: ${{ vars.MONGO_URI }}
MONGO_DB_HOST: ${{ vars.MONGO_DB_HOST }}
TOKEN_ISSUER: ${{ vars.TOKEN_ISSUER}}
TOKEN_AUDIENCE: ${{ vars.TOKEN_AUDIENCE}}
CORS_URL: ${{ vars.CORS_URL}}
FRONTEND_RESET_URL: ${{ vars.FRONTEND_RESET_URL}}
API_VERSION: ${{ vars.API_VERSION}}
ACCESS_TOKEN_SECRET_KEY: ${{ secrets.ACCESS_TOKEN_SECRET_KEY}}
MAILTRAP_TESTING_USERNAME: ${{ secrets.MAILTRAP_TESTING_USERNAME}}
MAILTRAP_TESTING_PASSWORD: ${{ secrets.MAILTRAP_TESTING_PASSWORD}}
MAILTRAP_TESTING_HOST: ${{ vars.MAILTRAP_TESTING_HOST}}
REFRESH_TOKEN_SECRET_KEY: ${{ secrets.REFRESH_TOKEN_SECRET_KEY}}
MAILTRAP_EMAIL_ENV: ${{ vars.MAILTRAP_EMAIL_ENV}}

- name: Save Devlopment Build Artifacts
uses: actions/upload-artifact@v4
with:
name: api-build
path: /build

# Step: Build the project
build-production:
needs: [build-development]
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout Code
uses: actions/checkout@v3

# Restore Modules cache
- name: Restore Modules Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-auth-${{ hashFiles('package-lock.json') }}

- name: Build for production
run: npm run build
working-directory: ./
env:
PORT: ${{ vars.API_PORT }}
MONGO_URI: ${{ vars.MONGO_URI }}
MONGO_DB_HOST: ${{ vars.MONGO_DB_HOST }}
TOKEN_ISSUER: ${{ vars.TOKEN_ISSUER}}
TOKEN_AUDIENCE: ${{ vars.TOKEN_AUDIENCE}}
CORS_URL: ${{ vars.CORS_URL}}
FRONTEND_RESET_URL: ${{ vars.FRONTEND_RESET_URL}}
API_VERSION: ${{ vars.API_VERSION}}
ACCESS_TOKEN_SECRET_KEY: ${{ secrets.ACCESS_TOKEN_SECRET_KEY}}
MAILTRAP_USERNAME: ${{ secrets.MAILTRAP_USERNAME}}
MAILTRAP_PASSWORD: ${{ secrets.MAILTRAP_PASSWORD}}
MAILTRAP_HOST: ${{ vars.MAILTRAP_HOST}}
REFRESH_TOKEN_SECRET_KEY: ${{ secrets.REFRESH_TOKEN_SECRET_KEY}}
MAILTRAP_EMAIL_ENV: ${{ vars.MAILTRAP_EMAIL_ENV}}

- name: Save Production Build Artifacts
uses: actions/upload-artifact@v4
with:
name: api-build
path: /build
6 changes: 2 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ services:
build:
# This defines the build context for the image build
context: ./
args:
NODE_ENV: production
# This is the name we’ll use to refer to this image in Docker commands or to push to a Docker registry.
image: sainiabhishek/nodejs_auth-api:1.1.0
container_name: api
Expand All @@ -36,8 +34,8 @@ services:
environment:
MONGO_URI: mongodb://mongo:27017/
MONGO_DB_HOST: mongo
TOKEN_ISSUER: api.prod.saini.com
TOKEN_AUDIENCE: prod.saini.com
TOKEN_ISSUER: api.dev.saini.com
TOKEN_AUDIENCE: dev.saini.com
FRONTEND_RESET_URL: http://localhost:3000/
CORS_URL: http://localhost:3000
MAILTRAP_EMAIL_ENV: testing
Expand Down
4 changes: 0 additions & 4 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ FROM node:20.17.0-slim AS production
# Install curl
RUN apt-get update && apt-get install -y curl

# Argument and environment variable for production mode
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}

# Set the working directory inside the final container
WORKDIR /app

Expand Down

0 comments on commit 3dabdbf

Please sign in to comment.