Skip to content

Commit

Permalink
chore: Update web CI and add Dockerfile for web
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Dec 29, 2023
1 parent 2cd521d commit fc9571e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 22 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
30 changes: 10 additions & 20 deletions .github/workflows/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,24 @@ jobs:
run: |
pnpm run test:web
deploy:
build:
needs: validate
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: Deploy
name: Build and push docker image

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v3
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
node-version: 20
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Install packages
run: |
pnpm i
- name: Build Docker image
run: docker build -t keyshade/keyshade-web:latest -f Dockerfile-web .

- name: Build and deploy
run: |
pnpm install --global vercel
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Push Docker image
run: docker push keyshade/keyshade-web
18 changes: 18 additions & 0 deletions Dockerfile-web
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:20-alpine as build

WORKDIR /app

RUN npm i -g pnpm

COPY package.json .
COPY tsconfig.base.json .

RUN pnpm install

COPY apps/web apps/web

RUN pnpm run build:web

EXPOSE 3000

ENTRYPOINT ["pnpm", "run", "start:web"]
1 change: 1 addition & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { composePlugins, withNx } = require('@nx/next')
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
distDir: 'dist/.next',
webpack(config, { isServer }) {
config.module.rules.push({
test: /\.svg$/,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"serve": {
"executor": "@nx/next:server",
"defaultConfiguration": "development",
"defaultConfiguration": "production",
"options": {
"buildTarget": "web:build",
"dev": true,
Expand Down
3 changes: 2 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"../../dist/apps/web/.next/types/**/*.ts",
"next-env.d.ts",
".next/types/**/*.ts",
"../../apps/web/dist/.next/types/**/*.ts"
"../../apps/web/dist/.next/types/**/*.ts",
"dist/.next/types/**/*.ts"
],
"exclude": [
"node_modules",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"test:workspace": "nx run workspace:test",
"test:cli": "nx run cli:test",
"test:sdk-node": "nx run sdk-js:test",
"start:web": "nx run web:serve",
"db:seed": "cd apps/api/src/prisma && pnpx ts-node seed.ts",
"db:generate-types": "nx run api:prisma:generate",
"db:generate-migrations": "cd apps/api/src/prisma && pnpx prisma migrate dev --create-only --skip-seed",
Expand Down

0 comments on commit fc9571e

Please sign in to comment.