feat: adds standalone build and a Dockerfile

This commit is contained in:
Vacharanon
2024-04-02 04:34:46 +07:00
committed by GitHub
parent ee7a92d1f3
commit e8d678d191
4 changed files with 77 additions and 2 deletions

29
Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
# Use the official Node.js runtime as the base image
FROM node:21 as build
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the entire application code to the container
COPY . .
# Build the React app for production
RUN npm run standalone
# Use Nginx as the production server
FROM nginx:alpine
# Copy the built React app to Nginx's web server directory
COPY --from=build /app/dist /usr/share/nginx/html
# Expose port 80 for the Nginx server
EXPOSE 80
# Start Nginx when the container runs
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -28,7 +28,7 @@ npm i @isoflow/isopacks
```jsx showLineNumbers
import Isoflow from 'isoflow';
import { flattenCollections } from 'isoflow/dist/utils';
import { flattenCollections } from '@isoflow/isopacks/dist/utils';
import isoflowIsopack from '@isoflow/isopacks/dist/isoflow';
import awsIsopack from '@isoflow/isopacks/dist/aws';
import gcpIsopack from '@isoflow/isopacks/dist/gcp';

View File

@@ -19,7 +19,8 @@
"lint:fix": "eslint --fix ./src/**/*.{ts,tsx}",
"docs:dev": "cd ./docs && npm run dev",
"docs:build": "cd ./docs && npm run build",
"docs:start": "cd ./docs && npm run start"
"docs:start": "cd ./docs && npm run start",
"standalone": "webpack --config ./webpack/standalone.config.js"
},
"devDependencies": {
"@isoflow/isopacks": "^0.0.10",

View File

@@ -0,0 +1,45 @@
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
module.exports = {
mode: 'production',
entry: './src/index.tsx',
target: 'web',
output: {
path: path.resolve(__dirname, '../dist'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/i,
type: 'asset/inline'
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: path.resolve(__dirname, '../src/index.html')
}),
new webpack.DefinePlugin({
PACKAGE_VERSION: JSON.stringify(require("../package.json").version),
REPOSITORY_URL: JSON.stringify(require("../package.json").repository.url),
})
],
resolve: {
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()]
}
};