Skip to content

Instantly share code, notes, and snippets.

@RagilPratama
Last active April 29, 2024 08:30
Show Gist options
  • Save RagilPratama/bbf243ed3305547be68f013b75bb1479 to your computer and use it in GitHub Desktop.
Save RagilPratama/bbf243ed3305547be68f013b75bb1479 to your computer and use it in GitHub Desktop.
# Build Project
FROM node:20.9.0-bullseye-slim
LABEL maintainer="RPE Team"
LABEL description="Anya Fund Switching and Allocation"
# Define argument
ARG STAGE
# set up directory file
RUN mkdir -p /home/node/app
WORKDIR /home/node/app
# COPY package.json
# COPY package*.json ./
# COPY npm-shrinkwrap.json ./
# COPY deploy/envs/microsite-dev.env .env
# Install the node modules
# RUN npm config set proxy http://165.225.112.16:10938
# RUN npm config set https-proxy http://165.225.112.16:10938
# RUN npm config set no_proxy localhost,127.0.0.1,*.aia.biz,aia.biz,10.132.45.26
# RUN npm install --registry http://nexus.digital.id.aia.biz/repository/npm-public/ --loglevel verbose
# Bundle App Source
# COPY deploy/envs/microsite-uat.env .env
# COPY . .
COPY deploy/envs ./deploy/envs
COPY src ./src
COPY .babelrc ./
COPY .nuxt ./.nuxt
COPY jest.config.js ./
COPY jsconfig.json ./
COPY nuxt.config.js ./
COPY package.*json ./
COPY node_modules ./node_modules
# Build app for production with minification
RUN chown -R node:node /home/node/app
# RUN cat .env | xargs -d '\n' -I {} sh -c 'export "{}"' && npm run build
# Harden docker image
COPY hardening.sh ./
RUN chmod +x ./hardening.sh && ./hardening.sh && sleep 2 && rm -rf ./hardening.sh
# expose server
EXPOSE 3000
USER 1000
#delete private key
RUN npm run privatekey:clean
# CMD ["npm", "run", "start"];
ENTRYPOINT ["npm","run","start"]
import path from 'path'
// import webpack from 'webpack'
import { format, transports } from 'winston'
const env = process.env.ENV === 'production' ? "aia" : process.env.ENV
//console.log('path',__dirname + `/deploy/envs/microsite-${env}.env`)
require('dotenv').config({ path: __dirname + `/deploy/envs/microsite-${env}.env` })
//require('dotenv').config({})
const routerBase = process.env.ROUTER_BASE || ''
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
build: {
transpile: ['vue-mask','otp-input-vue2']
},
ssr: true,
render:{
// csp:{
// policies:{
// 'script-src ' : ['*'],
// 'img-src ' : ['*','data:'],
// 'font-src ' : ['*'],
// 'style-src ' : ['*'],
// 'connect-src ' : ['*'],
// },
// addMeta:true,
// unsafeInlineCompatibility: true,
// }
},
target: 'server',
head: {
titleTemplate: 'anya',
title: 'anya',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
script: [
// - recaptcha
{
src:'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js',
},
{
src: 'https://www.google.com/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit',
async: true,
defer: true
},
{
src: 'https://js-cdn.dynatrace.com/jstag/17f2114f5d1/bf31048ntc/851da982414ec6ff_complete.js',
},
{
src: 'https://aia-dfs.originally.us/web-uat/feedbackSdk.min.js',
},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: 'favicon.ico' },
{ rel: 'stylesheet', type: 'text/css', href: 'css/fonts.css', media: 'screen', disabled: false },
{ rel: 'stylesheet', type: 'text/css', href: 'css/materialdesignicons.css', media: 'screen', disabled: false },
{ rel: 'stylesheet', type: 'text/css', href: 'css/google-font.css', media: 'screen', disabled: false },
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap'
},
{
rel: 'stylesheet',
href: 'https://aia-dfs.originally.us/web-p3/feedbackSdk.css'
}
]
},
env: {
url: process.env.BASE_URL,
gsiteKey: process.env.GSITE_KEY,
api_key: process.env.API_KEY,
content_type: process.env.CONTENT_TYPE,
authorization: process.env.AUTHORIZATION,
routerBase: routerBase
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'../src/assets/style/main.css'
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
'plugins/vuetify.js',
'plugins/services.js',
{ src: 'plugins/mask.js', ssr: true },
{ src: 'plugins/helpers.js', ssr: true },
{ src: '~plugins/axios-host.js', ssr: true },
{ src: '~plugins/loader.js', ssr: false },
{ src: '~plugins/currency-format.js', ssr: false },
{ src: '~plugins/rating-service.js', ssr: false },
{ src: '~plugins/dynatrace-service.js', ssr: false },
{ src: '~plugins/route-guard.js', ssr: false },
{ src: '~plugins/removeConsoleLog.js', mode: 'client' }
],
// source directory
srcDir: 'src/',
serverMiddleware: [
{ path: '/', handler: '~/api/app.js' },
{ path: '~/api/logger', handler: '~/api/logger.js' }
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: {
dirs: [
'views/components',
{
path: 'views/components/atoms/',
prefix: 'A'
},
{
path: 'views/components/molecules/',
prefix: 'M'
},
{
path: 'views/components/organisms/',
prefix: 'O'
}
]
},
// custom directory (if keyName != name custom directory)
dir: {
layouts: 'views/components/templates',
pages: 'views/pages'
},
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/eslint
// '@nuxtjs/eslint-module',
// '@nuxtjs/dotenv',
'@nuxtjs/vuetify',
'@nuxtjs/moment'
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@privyid/nuxt-csrf',
'@nuxtjs/axios',
['cookie-universal-nuxt', { alias: 'cookiz' }],
],
// winstonLog: {
// transportOptions: {
// filename: logfilePath
// },
// loggerOptions: {
// format: combine(
// timestamp(),
// prettyPrint()
// )
// }
// },
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
optimization:{
splitChunks: {
chunks: 'all',
automaticNameDelimiter: '.',
cacheGroups: {
vuetify: {
name: 'vuetify',
test: /[\\/]node_modules[\\/](vuetify)[\\/]/,
chunks: 'all',
priority: -5,
maxSize: 244 * 1024,
enforce: true
},
vendors: {
name: 'vendors',
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
priority: -15,
maxSize: 244 * 1024,
enforce: true
},
commons: {
name: 'commons',
test: /[\\/]node_modules[\\/]/,
chunks: 'initial',
priority: -20,
maxSize: 244 * 1024,
enforce: true
}
}
}
},
transpile: [({ isLegacy }) => isLegacy && 'axios'],
loaders: {
sass: {
implementation: require('sass'),
},
scss: {
implementation: require('sass'),
},
},
// extend(config, { isDev, isClient }) {
// if(!isDev && !isClient){
// config.optimization.minimizer[0].options.terserOptions.compress = {
// drop_console: true,
// };
// }
// }
},
server: {
port: process.env.PORT || 3000, // default: 3000
host: process.env.HOST || "localhost" // default: localhost,
},
router:{
middleware: ['auth'],
base: routerBase
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment