initial docker detup

This commit is contained in:
Danny Avila 2023-03-06 12:49:22 -05:00
parent f5e079742a
commit ff7b016190
11 changed files with 84 additions and 14 deletions

2
client/.dockerignore Normal file
View file

@ -0,0 +1,2 @@
/node_modules
.env

18
client/Dockerfile Normal file
View file

@ -0,0 +1,18 @@
# Stage 1
FROM node:19-alpine as builder
WORKDIR /client
# copy package.json into the container at /client
COPY package*.json /client/
# install dependencies
RUN npm install
# Copy the current directory contents into the container at /client
COPY . /client/
# Run the app when the container launches
CMD ["npm", "run", "build"]
# Stage 2
FROM nginx:stable-alpine
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=builder /client/public /usr/share/nginx/html
ENTRYPOINT ["nginx", "-g", "daemon off;"]

View file

@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "Webpack .",
"build": "webpack",
"build-dev": "Webpack . --watch"
},
"repository": {

View file

@ -2,7 +2,7 @@ import React from 'react';
import RenameIcon from '../svg/RenameIcon';
import CheckMark from '../svg/CheckMark';
export default function RenameButton({ onClick, renaming, renameHandler, onRename }) {
export default function RenameButton({ renaming, renameHandler, onRename }) {
const handler = renaming ? onRename : renameHandler;
return (

View file

@ -12,7 +12,7 @@ const initialState = {
promptPrefix: null,
convosLoading: false,
pageNumber: 1,
convos: [],
convos: []
};
const currentSlice = createSlice({
@ -32,8 +32,10 @@ const currentSlice = createSlice({
const newConvos = action.payload.filter((convo) => {
return !state.convos.some((c) => c.conversationId === convo.conversationId);
});
state.convos = [...state.convos, ...newConvos];
},
state.convos = [...state.convos, ...newConvos].sort(
(a, b) => new Date(b.created) - new Date(a.created)
);
}
}
});

View file

@ -1,46 +0,0 @@
const primaryRegex = /```([^`\n]*?)\n([\s\S]*?)\n```/g;
const secondaryRegex = /```([^`\n]*?)\n?([\s\S]*?)\n?```/g;
const unenclosedCodeTest = (text) => {
let workingText = text;
// if (workingText.startsWith('<') || (!workingText.startsWith('`') && workingText.match(/```/g)?.length === 1)) {
// workingText = `\`\`\`${workingText}`
// }
return workingText.trim();
};
export default function regexSplit(string) {
let matches = [...string.matchAll(primaryRegex)];
if (!matches[0]) {
matches = [...string.matchAll(secondaryRegex)];
}
const output = [matches[0].input.slice(0, matches[0].index)];
// console.log(matches);
for (let i = 0; i < matches.length; i++) {
const [fullMatch, language, code] = matches[i];
// const formattedCode = code.replace(/`+/g, '\\`');
output.push(`\`\`\`${language}\n${code}\n\`\`\``);
if (i < matches.length - 1) {
let nextText = string.slice(matches[i].index + fullMatch.length, matches[i + 1].index);
nextText = unenclosedCodeTest(nextText);
output.push(nextText);
} else {
const lastMatch = matches[matches.length - 1][0];
// console.log(lastMatch);
// console.log(matches[0].input.split(lastMatch));
let rest = matches[0].input.split(lastMatch)[1]
if (rest) {
rest = unenclosedCodeTest(rest);
output.push(rest);
}
}
}
return output;
}