-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from pramod444/develop
[G2P-2014] Renamed docker. Added formaters and linters.
- Loading branch information
Showing
77 changed files
with
6,646 additions
and
3,533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# add git-ignore syntax here of things you don't want copied into docker image | ||
|
||
.git | ||
.results | ||
scripts | ||
*Dockerfile* | ||
node_modules | ||
.env | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Configuration for known file extensions | ||
[*.{css,js,jsx,ts,tsx,json,less,md,py,rst,sass,scss,xml,yaml,yml,toml,jinja}] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
# Do not configure editor for libs and autogenerated content | ||
[{*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst}] | ||
charset = unset | ||
end_of_line = unset | ||
indent_size = unset | ||
indent_style = unset | ||
insert_final_newline = false | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "next/core-web-vitals", | ||
"plugins": ["unused-imports"], | ||
"rules": { | ||
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off", | ||
"unused-imports/no-unused-imports": "error", | ||
"unused-imports/no-unused-vars": [ | ||
"warn", | ||
{"vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_"} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Build Docker and Push | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
docker-build: | ||
name: Docker Build and Push | ||
runs-on: ubuntu-latest | ||
env: | ||
NAMESPACE: ${{ secrets.docker_hub_organisation }} | ||
SELFSERVICE_SERVICE_NAME: "openg2p-selfservice-ui" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup branch and env | ||
run: | | ||
# Strip git ref prefix from version | ||
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,') | ||
VERSION=$BRANCH_NAME | ||
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then | ||
VERSION=develop | ||
fi | ||
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Build docker | ||
run: | | ||
SELFSERVICE_IMAGE_ID=$NAMESPACE/$SELFSERVICE_SERVICE_NAME | ||
# Change all uppercase to lowercase | ||
SELFSERVICE_IMAGE_ID=$(echo $SELFSERVICE_IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
echo SELFSERVICE_IMAGE_ID=$SELFSERVICE_IMAGE_ID | ||
echo VERSION=$VERSION | ||
echo "SELFSERVICE_IMAGE_ID=$SELFSERVICE_IMAGE_ID" >> $GITHUB_ENV | ||
docker build . \ | ||
--file Dockerfile \ | ||
--tag $SELFSERVICE_IMAGE_ID:$VERSION | ||
docker build . \ | ||
--file Dockerfile.no-runtime-build \ | ||
--tag $SELFSERVICE_IMAGE_ID:$VERSION-no-runtime-build | ||
- name: Docker login | ||
run: | | ||
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin | ||
if [ $? -ne 0 ];then | ||
echo "::error::Failed to Login to dockerhub" | ||
exit 1; | ||
fi | ||
- name: Docker Push images | ||
run: | | ||
docker push $SELFSERVICE_IMAGE_ID:$VERSION | ||
docker push $SELFSERVICE_IMAGE_ID:$VERSION-no-runtime-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,4 @@ yarn-error.log* | |
.vercel | ||
|
||
# Typescript | ||
*.tsbuildinfo | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.prettierignore | ||
public/ | ||
.gitignore | ||
.husky/ | ||
.next/ | ||
dist | ||
node_modules | ||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Defaults for all prettier-supported languages. | ||
# Prettier will complete this with settings from .editorconfig file. | ||
bracketSpacing: false | ||
printWidth: 110 | ||
proseWrap: always | ||
semi: true | ||
trailingComma: "es5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM node:18-alpine AS base | ||
|
||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
WORKDIR /app | ||
|
||
RUN chown -R nextjs:nodejs /app | ||
|
||
USER nextjs | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY --chown=nextjs:nodejs package.json package-lock.json* ./ | ||
RUN npm ci | ||
|
||
COPY --chown=nextjs:nodejs . . | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
ENV NODE_ENV=production | ||
ENV HOSTNAME="0.0.0.0" | ||
ENV PORT=3000 | ||
|
||
EXPOSE 3000 | ||
|
||
CMD npm run build && npm run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM node:18-alpine AS base | ||
|
||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
WORKDIR /app | ||
|
||
RUN chown -R nextjs:nodejs /app | ||
|
||
USER nextjs | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY --chown=nextjs:nodejs package.json package-lock.json* ./ | ||
RUN npm ci | ||
|
||
COPY --chown=nextjs:nodejs . . | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
ARG NEXT_TELEMETRY_DISABLED=1 | ||
ARG NODE_ENV=production | ||
ARG HOSTNAME="0.0.0.0" | ||
ARG PORT=3000 | ||
ARG NEXT_PUBLIC_BASE_PATH=/selfservice | ||
ARG NEXT_PUBLIC_BASE_API_PATH=/selfservice/v1 | ||
|
||
EXPOSE 3000 | ||
|
||
RUN npm run build | ||
CMD npm run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# openg2p-portal | ||
OpenG2P beneficiary self service portal | ||
# OpenG2P Beneficiary Portal | ||
|
||
OpenG2P beneficiary self service portal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,39 @@ | ||
import { NextResponse } from 'next/server' | ||
import type { NextRequest } from 'next/server' | ||
import {NextResponse} from "next/server"; | ||
import type {NextRequest} from "next/server"; | ||
|
||
import { i18n } from '@/i18n.config' | ||
import {i18n} from "@/i18n.config"; | ||
|
||
import { match as matchLocale } from '@formatjs/intl-localematcher' | ||
import Negotiator from 'negotiator' | ||
import {match as matchLocale} from "@formatjs/intl-localematcher"; | ||
import Negotiator from "negotiator"; | ||
|
||
function getLocale(request: NextRequest): string | undefined { | ||
const negotiatorHeaders: Record<string, string> = {} | ||
request.headers.forEach((value, key) => (negotiatorHeaders[key] = value)) | ||
const negotiatorHeaders: Record<string, string> = {}; | ||
request.headers.forEach((value, key) => (negotiatorHeaders[key] = value)); | ||
|
||
// @ts-ignore locales are readonly | ||
const locales: string[] = i18n.locales | ||
const languages = new Negotiator({ headers: negotiatorHeaders }).languages() | ||
const locales: string[] = i18n.locales; | ||
const languages = new Negotiator({headers: negotiatorHeaders}).languages(); | ||
|
||
const locale = matchLocale(languages, locales, i18n.defaultLocale) | ||
return locale | ||
const locale = matchLocale(languages, locales, i18n.defaultLocale); | ||
return locale; | ||
} | ||
|
||
export function middleware(request: NextRequest) { | ||
const pathname = request.nextUrl.pathname | ||
const pathname = request.nextUrl.pathname; | ||
const pathnameIsMissingLocale = i18n.locales.every( | ||
locale => !pathname.startsWith(`/${locale}/`) && pathname !== `/${locale}` | ||
) | ||
(locale) => !pathname.startsWith(`/${locale}/`) && pathname !== `/${locale}` | ||
); | ||
|
||
// Redirect if there is no locale | ||
if (pathnameIsMissingLocale) { | ||
const locale = getLocale(request) | ||
const locale = getLocale(request); | ||
return NextResponse.redirect( | ||
new URL( | ||
`/${locale}${pathname.startsWith('/') ? '' : '/'}${pathname}`, | ||
request.url | ||
) | ||
) | ||
new URL(`/${locale}${pathname.startsWith("/") ? "" : "/"}${pathname}`, request.url) | ||
); | ||
} | ||
} | ||
|
||
export const config = { | ||
// Matcher ignoring `/_next/` and `/api/` | ||
matcher: ['/((?!api|_next/static|_next/image|img|favicon.ico|/img).*)'] | ||
} | ||
matcher: ["/((?!api|_next/static|_next/image|img|favicon.ico|/img).*)"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig | ||
|
||
const nextConfig = { | ||
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "", | ||
}; | ||
|
||
module.exports = nextConfig; |
Oops, something went wrong.