Project seeded
Signed-off-by: James Ketrenos <james@ketrenos.com>
This commit is contained in:
parent
afa9a7d185
commit
3e5d4b0cbf
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
.git
|
||||
**/node_modules
|
4
.env
Normal file
4
.env
Normal file
@ -0,0 +1,4 @@
|
||||
HOST=localhost
|
||||
HTTPS=true
|
||||
DANGEROUSLY_DISABLE_HOST_CHECK='true'
|
||||
WDS_SOCKET_PORT=0
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
logs/*
|
108
Dockerfile
Normal file
108
Dockerfile
Normal file
@ -0,0 +1,108 @@
|
||||
FROM ubuntu:jammy AS nodejs
|
||||
|
||||
RUN apt-get -q update \
|
||||
&& apt-get upgrade -y
|
||||
|
||||
# Switch to bash instead of sh
|
||||
RUN apt-get -q update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||
ca-certificates \
|
||||
wget \
|
||||
unzip \
|
||||
&& update-ca-certificates --fresh
|
||||
|
||||
RUN wget -qO- https://deb.nodesource.com/setup_18.x | bash -
|
||||
|
||||
FROM nodejs AS runtime
|
||||
|
||||
RUN apt-get -q update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install \
|
||||
--no-install-recommends -y \
|
||||
nodejs \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} \
|
||||
&& npm install -g npm@latest
|
||||
|
||||
RUN apt-get -q update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install \
|
||||
--no-install-recommends -y \
|
||||
rsync \
|
||||
wget \
|
||||
curl \
|
||||
nginx \
|
||||
shellinabox \
|
||||
nano \
|
||||
less \
|
||||
iputils-ping \
|
||||
curl \
|
||||
jq \
|
||||
sqlite3 \
|
||||
tree \
|
||||
inotify-tools \
|
||||
gettext-base \
|
||||
gh \
|
||||
git \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
||||
|
||||
SHELL [ "/bin/bash", "-c" ]
|
||||
|
||||
ARG DEVELOPMENT
|
||||
ENV DEVELOPMENT=${DEVELOPMENT:-}
|
||||
ARG CHAT_BASE
|
||||
ENV CHAT_BASE=${CHAT_BASE}
|
||||
ARG CHAT_URL
|
||||
ENV CHAT_URL=${CHAT_URL}
|
||||
|
||||
COPY /.env /home/user/.env
|
||||
RUN { \
|
||||
echo "REACT_APP_CHAT_URL=${CHAT_URL}" ; \
|
||||
echo "REACT_APP_CHAT_BASE=${CHAT_BASE}" ; \
|
||||
echo "WDS_SOCKET_PATH=${CHAT_BASE}/ws" ; \
|
||||
echo "PUBLIC_URL=${CHAT_BASE}" ; \
|
||||
echo "WDS_SOCKET_HOST=${CHAT_URL#http*://}" ; \
|
||||
} | tee -a /home/user/.env
|
||||
|
||||
COPY /server /home/user/server
|
||||
COPY /server/nginx.conf /etc/nginx/sites-enabled/default
|
||||
WORKDIR /home/user/server
|
||||
RUN npm install
|
||||
|
||||
COPY /client /home/user/client
|
||||
WORKDIR /home/user/client
|
||||
RUN npm install
|
||||
|
||||
# If not DEVELOPMENT mode, copy production config, else development
|
||||
RUN \
|
||||
if [[ -z "${DEVELOPMENT}" ]]; then \
|
||||
echo "Building PRODUCTION" ; \
|
||||
cp /home/user/server/production.location \
|
||||
/etc/nginx/snippets/active.location ; \
|
||||
else \
|
||||
echo "Building DEVELOPMENT" ; \
|
||||
cp /home/user/server/development.location \
|
||||
/etc/nginx/snippets/active.location ; \
|
||||
fi
|
||||
|
||||
# If not DEVELOPMENT mode, then locally build project
|
||||
RUN \
|
||||
if [[ -z "${DEVELOPMENT}" ]]; then \
|
||||
cd /home/user/client ; \
|
||||
npm run build ; \
|
||||
fi
|
||||
|
||||
COPY /scripts /opt/scripts
|
||||
|
||||
ENV PATH="${PATH}:/opt/scripts"
|
||||
|
||||
COPY /Dockerfile /home/user/Dockerfile
|
||||
|
||||
# alias out 'sudo' since USER is root and we want to copy/paste
|
||||
# commands from our README.md that contains 'sudo'
|
||||
RUN echo "alias sudo=" >> /root/.bashrc
|
||||
|
||||
# In DEVELOPMENT mode, entrypoint launches 'npm start'
|
||||
WORKDIR /home/user
|
||||
COPY /entrypoint.sh /
|
||||
CMD [ "/opt/scripts/irepo-shell" ]
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
33
README.md
33
README.md
@ -0,0 +1,33 @@
|
||||
# Ketr Chat
|
||||
|
||||
## To build
|
||||
|
||||
```bash
|
||||
git clone https://git.ketrenos.com/jketreno/ketr.chat.git
|
||||
cd ketr.chat
|
||||
./build
|
||||
```
|
||||
|
||||
## To run
|
||||
|
||||
```bash
|
||||
DEVELOPMENT=1 ./launch
|
||||
```
|
||||
|
||||
## To develop Web UI
|
||||
|
||||
```bash
|
||||
DEVELOPMENT=1 ./launch
|
||||
./shell
|
||||
cd /home/user/client
|
||||
kill-client ; npm start
|
||||
```
|
||||
|
||||
## To develop backend
|
||||
|
||||
```bash
|
||||
DEVELOPMENT=1 ./launch
|
||||
./shell
|
||||
cd /home/user/server
|
||||
kill-server ; npm start
|
||||
```
|
11
build
Executable file
11
build
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
export CHAT_URL="https://$(hostname).ketrenos.com"
|
||||
export CHAT_BASE="/ketr.chat"
|
||||
|
||||
echo "Building with:"
|
||||
echo " CHAT_URL to ${CHAT_URL}"
|
||||
echo " CHAT_BASE to ${CHAT_BASE}"
|
||||
docker-compose build \
|
||||
--build-arg=CHAT_URL="${CHAT_URL}" \
|
||||
--build-arg=CHAT_BASE="${CHAT_BASE}" \
|
||||
--parallel
|
23
client/.gitignore
vendored
Normal file
23
client/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
70
client/README.md
Normal file
70
client/README.md
Normal file
@ -0,0 +1,70 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
||||
|
||||
The page will reload when you make changes.\
|
||||
You may also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
|
||||
### Code Splitting
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
||||
|
||||
### Making a Progressive Web App
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
||||
|
||||
### Deployment
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
||||
|
||||
### `npm run build` fails to minify
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
17692
client/package-lock.json
generated
Normal file
17692
client/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
54
client/package.json
Normal file
54
client/package.json
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "client",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.10.6",
|
||||
"@emotion/styled": "^11.10.6",
|
||||
"@mui/icons-material": "^5.10.16",
|
||||
"@mui/material": "^5.11.10",
|
||||
"@types/jest": "^29.2.3",
|
||||
"@types/node": "^18.11.10",
|
||||
"@types/react": "^18.0.26",
|
||||
"@types/react-dom": "^18.0.9",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"history": "^5.3.0",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"moment": "^2.29.4",
|
||||
"moment-timezone": "^0.5.39",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-moment": "^1.1.2",
|
||||
"react-movable": "^3.0.4",
|
||||
"react-moveable": "^0.43.1",
|
||||
"react-router": "^6.4.4",
|
||||
"react-router-dom": "^6.4.4",
|
||||
"react-scripts": "^5.0.1",
|
||||
"react-select": "^5.7.0",
|
||||
"react-spinners": "^0.13.6"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "export $(cat ../.env | xargs) && react-scripts start",
|
||||
"build": "export $(cat ../.env | xargs) && react-scripts build",
|
||||
"test": "export $(cat ../.env | xargs) && react-scripts test",
|
||||
"eject": "export $(cat ../.env | xargs) && react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
BIN
client/public/favicon.ico
Normal file
BIN
client/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
43
client/public/index.html
Normal file
43
client/public/index.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
BIN
client/public/logo192.png
Normal file
BIN
client/public/logo192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
client/public/logo512.png
Normal file
BIN
client/public/logo512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
25
client/public/manifest.json
Normal file
25
client/public/manifest.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
3
client/public/robots.txt
Normal file
3
client/public/robots.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
38
client/src/App.css
Normal file
38
client/src/App.css
Normal file
@ -0,0 +1,38 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
15
client/src/App.js
Normal file
15
client/src/App.js
Normal file
@ -0,0 +1,15 @@
|
||||
import './App.css';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<p>
|
||||
Edit <code>src/App.js</code> and save to reload.
|
||||
</p>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
13
client/src/index.css
Normal file
13
client/src/index.css
Normal file
@ -0,0 +1,13 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
11
client/src/index.js
Normal file
11
client/src/index.js
Normal file
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
24
development.yml
Normal file
24
development.yml
Normal file
@ -0,0 +1,24 @@
|
||||
version: '3.1'
|
||||
services:
|
||||
ketr.chat:
|
||||
volumes:
|
||||
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
|
||||
- $HOME/.netrc:/root/.netrc # Use current user .netrc
|
||||
- $HOME/.config/gh:/root/.config/gh # Use current user GH config
|
||||
- ./logs:/home/user/logs #
|
||||
# Hot mount client and server for dynamic changes in DEVELOPMENT
|
||||
- ./scripts:/opt/scripts # Hot update via bind
|
||||
- ./server/app.js:/home/user/server/app.js
|
||||
- ./server/config:/home/user/server/config
|
||||
- ./server/package.json:/home/user/server/package.json
|
||||
- ./server/package-lock.json:/home/user/server/package-lock.json
|
||||
- ./server/routes:/home/user/server/routes
|
||||
- ./server/nginx.conf:/etc/nginx/sites-available/default
|
||||
- ./client/package.json:/home/user/client/package.json
|
||||
- ./client/package-lock.json:/home/user/client/package-lock.json
|
||||
- ./client/build:/home/user/client/build
|
||||
- ./client/public:/home/user/client/public
|
||||
- ./client/src:/home/user/client/src
|
||||
ports:
|
||||
- 127.0.0.1:19876:80 # Main app entrypoint
|
||||
- 127.0.0.1:14200:4200 # shellinabox
|
42
docker-compose.yml
Executable file
42
docker-compose.yml
Executable file
@ -0,0 +1,42 @@
|
||||
version: "3.1"
|
||||
services:
|
||||
ketr.chat:
|
||||
image: ketr.chat:development
|
||||
env_file:
|
||||
- .env
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
DEVELOPMENT: 1
|
||||
stdin_open: true # Needed for react-scripts
|
||||
tty: true # Needed for react-scripts
|
||||
restart: always
|
||||
volumes:
|
||||
- $HOME/.netrc:/root/.netrc # Use current user .netrc
|
||||
- $HOME/.config/gh:/root/.config/gh # GitHub 'gh' credentials for GitHub actions
|
||||
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
|
||||
- ./logs:/home/user/logs #
|
||||
ports:
|
||||
- 127.0.0.1:19876:80
|
||||
|
||||
ketr.chat-production:
|
||||
image: ketr.chat:production
|
||||
env_file:
|
||||
- .env
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
DEVELOPMENT:
|
||||
stdin_open: true # Needed for react-scripts
|
||||
tty: true # Needed for react-scripts
|
||||
restart: always
|
||||
volumes:
|
||||
- $HOME/.netrc:/root/.netrc # Use current user .netrc
|
||||
- $HOME/.config/gh:/root/.config/gh # GitHub 'gh' credentials for GitHub actions
|
||||
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
|
||||
- ./scripts:/opt/scripts # Hot update via bind
|
||||
ports:
|
||||
- 127.0.0.1:19876:80
|
||||
|
37
entrypoint.sh
Executable file
37
entrypoint.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/sbin/nginx
|
||||
|
||||
mkdir -p /var/lib/shellinabox
|
||||
chmod a+rwX /var/lib/shellinabox
|
||||
/usr/bin/shellinaboxd --debug --no-beep --disable-peer-check \
|
||||
-t \
|
||||
-b \
|
||||
-c /var/lib/shellinabox \
|
||||
-s "/:root:root:/home/user:/bin/bash"
|
||||
|
||||
if [[ ! -d /home/user/logs/nginx ]]; then
|
||||
mkdir -p /home/user/logs/nginx
|
||||
fi
|
||||
if [[ ! -L /home/user/logs/nginx/access.log ]]; then
|
||||
ln -sf /var/log/nginx/access.log /home/user/logs/nginx/access.log
|
||||
fi
|
||||
|
||||
if [[ "${CHAT_BASE}" != "" ]]; then
|
||||
echo "Setting ${CHAT_BASE} in client/public/tail-pre-html"
|
||||
sed -i -E "s#/ketr.chat#${CHAT_BASE}#g" client/public/tail-pre.html
|
||||
fi
|
||||
|
||||
if [[ -z "${DEVELOPMENT}" ]]; then
|
||||
echo "Running in PRODUCTION mode."
|
||||
cd /home/user/server
|
||||
{ while true; do npm start ; sleep 3 ; done ; }
|
||||
else
|
||||
echo "Running in DEVELOPMENT mode."
|
||||
cd /home/user/server
|
||||
npm install
|
||||
{ while true; do npm start ; sleep 3 ; done ; } &
|
||||
cd /home/user/client
|
||||
npm install
|
||||
{ while true; do npm start ; sleep 3 ; done ; }
|
||||
fi
|
24
launch
Executable file
24
launch
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
. .env
|
||||
|
||||
container=$(docker-compose ps -q)
|
||||
if [[ "${container}" != "" ]]; then
|
||||
name=$(docker container ls -f id=${container} --format "{{.Names}}")
|
||||
if [[ "${name}" == "" ]]; then
|
||||
>&2 echo "No container name found for ${container}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
>&2 echo "ketr.chat is already running as ${name}. Try './shell'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z ${DEVELOPMENT} ]]; then
|
||||
echo "Launching PRODUCTION"
|
||||
docker-compose \
|
||||
-f docker-compose.yml -f production.yml up -d ketr.chat-production $@
|
||||
else
|
||||
echo "Launching DEVELOPMENT"
|
||||
docker-compose \
|
||||
-f docker-compose.yml -f development.yml up -d ketr.chat $@
|
||||
fi
|
9
production.yml
Normal file
9
production.yml
Normal file
@ -0,0 +1,9 @@
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
ketr.chat-production:
|
||||
volumes:
|
||||
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
|
||||
- $HOME/.netrc:/root/.netrc # Use current user .netrc
|
||||
- $HOME/.config/gh:/root/.config/gh # Use current user GH config
|
||||
- ./logs:/home/user/logs #
|
14
scripts/kill-client
Executable file
14
scripts/kill-client
Executable file
@ -0,0 +1,14 @@
|
||||
|
||||
#!/bin/bash
|
||||
pids=($(ps aux |
|
||||
grep '[0-9] .*node.* /home/user/client' |
|
||||
while read user pid rest; do
|
||||
echo $pid;
|
||||
done))
|
||||
|
||||
if [[ "${pids}" != "" ]]; then
|
||||
echo "Killing ${pids[@]}."
|
||||
kill ${pids[@]}
|
||||
else
|
||||
echo "Running client not found."
|
||||
fi
|
12
scripts/kill-nginx
Executable file
12
scripts/kill-nginx
Executable file
@ -0,0 +1,12 @@
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
pid=$(ps aux |
|
||||
grep '[0-9] nginx' |
|
||||
while read user pid rest; do
|
||||
echo $pid;
|
||||
done)
|
||||
if [[ "$pid" != "" ]]; then
|
||||
kill $pid
|
||||
fi
|
||||
|
10
scripts/kill-server
Executable file
10
scripts/kill-server
Executable file
@ -0,0 +1,10 @@
|
||||
|
||||
#!/bin/bash
|
||||
pid=$(ps aux |
|
||||
grep '[0-9] node app.js' |
|
||||
while read user pid rest; do
|
||||
echo $pid;
|
||||
done)
|
||||
if [[ "$pid" != "" ]]; then
|
||||
kill $pid
|
||||
fi
|
2
scripts/shell
Executable file
2
scripts/shell
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
/bin/bash ${*}
|
0
server/app.js
Normal file
0
server/app.js
Normal file
15
server/development.location
Normal file
15
server/development.location
Normal file
@ -0,0 +1,15 @@
|
||||
# DEVELOPMENT -- use npm development server on port 3000 (entrypoint.sh)
|
||||
location / {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_pass_header Set-Cookie;
|
||||
proxy_pass_header P3P;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_pass https://localhost:3000/ketr.chat/;
|
||||
}
|
||||
|
46
server/nginx.conf
Normal file
46
server/nginx.conf
Normal file
@ -0,0 +1,46 @@
|
||||
server {
|
||||
root /home/user;
|
||||
index index.html;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log stderr;
|
||||
|
||||
autoindex on;
|
||||
|
||||
# proxy_pass has automatic redirect from v1 -> v1/
|
||||
# Set the API redirect early in case endpoints have similar names
|
||||
# to other location matches.
|
||||
location /api/v1/ {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_pass_header Set-Cookie;
|
||||
proxy_pass_header P3P;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_pass http://localhost:8911/api/v1/;
|
||||
}
|
||||
|
||||
# Set tail-pre injection for log files
|
||||
location ~ .*/*\.log$ {
|
||||
add_header Cache-Control "no-cache";
|
||||
add_before_body /tail-pre.html;
|
||||
default_type text/html;
|
||||
add_after_body /tail-post.html;
|
||||
}
|
||||
location ~ /tail.*\.(html|js|css) {
|
||||
root /home/user/client/public/;
|
||||
}
|
||||
|
||||
# 'active.conf' is copied during docker build based on whether
|
||||
# DEVELOPMENT is set (development.conf) or not (production.conf)
|
||||
include snippets/active.location;
|
||||
|
||||
location ~ /(db|conf) {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
}
|
1983
server/package-lock.json
generated
Normal file
1983
server/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
29
server/package.json
Normal file
29
server/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "ketr.chat-server",
|
||||
"version": "1.0.0",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"start": "export $(cat ../.env | xargs) && node app.js"
|
||||
},
|
||||
"author": "James Ketrenos <james_ketr_chat@ketrenos.com>",
|
||||
"license": "LICENSE FILE LICENSE",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"bluebird": "^3.5.5",
|
||||
"body-parser": "^1.19.2",
|
||||
"config": "^3.1.0",
|
||||
"connect-sqlite3": "^0.9.11",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"core-js": "^3.21.1",
|
||||
"express": "^4.17.3",
|
||||
"express-session": "^1.17.1",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"https-proxy-agent": "^5.0.1",
|
||||
"moment": "^2.24.0",
|
||||
"morgan": "^1.9.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"node-gzip": "^1.1.2",
|
||||
"nodemailer": "^6.3.0",
|
||||
"typeface-roboto": "0.0.75"
|
||||
}
|
||||
}
|
6
server/production.location
Normal file
6
server/production.location
Normal file
@ -0,0 +1,6 @@
|
||||
# PRODUCTION -- pre-built source
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
alias /home/user/client/build/;
|
||||
index index.html;
|
||||
}
|
24
shell
Executable file
24
shell
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
container=$(docker-compose ps -q)
|
||||
if [[ "${container}" == "" ]]; then
|
||||
>&2 echo "ketr.chat not running. Try './launch'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
name=$(docker container ls -f id="${container}" --format "{{.Names}}")
|
||||
if [[ "${name}" == "" ]]; then
|
||||
>&2 echo "No container name found for ${container}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command="${@}"
|
||||
command="${command:-/opt/scripts/shell}"
|
||||
|
||||
if [[ "${name}" =~ -production ]]; then
|
||||
echo "Starting shell in PRODUCTION"
|
||||
docker exec -it "${name}" ${command}
|
||||
else
|
||||
echo "Starting shell in DEVELOPMENT"
|
||||
docker exec -it "${name}" ${command}
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user