Use cerc/webapp-base as Docker base image.

This commit is contained in:
Thomas E Lackey 2023-08-17 14:34:45 -05:00
parent ac26f6f46d
commit 0acc9d1524
5 changed files with 32 additions and 14 deletions

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM node:18-alpine3.15 as builder
WORKDIR /app
COPY . .
RUN rm -rf node_modules && rm -rf build && yarn install
RUN yarn build
FROM cerc/webapp-base:local
COPY config.yml /config
RUN mkdir -p /data
COPY --from=builder /app/build /data

4
config.yml Normal file
View File

@ -0,0 +1,4 @@
web:
path: ''
api:
url: 'http://localhost:9393'

View File

@ -1,8 +1,8 @@
{ {
"name": "react-login-page", "name": "react-login-page",
"version": "0.1.0", "version": "0.1.0",
"homepage": "/newuser/",
"private": true, "private": true,
"homepage": "LACONIC_HOSTED_CONFIG_web_path",
"dependencies": { "dependencies": {
"react": "^16.8.6", "react": "^16.8.6",
"react-dom": "^16.8.6", "react-dom": "^16.8.6",
@ -11,7 +11,8 @@
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "clean": "rm -rf build",
"build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },

View File

@ -10,15 +10,13 @@ import HomePage from './components/pages/HomePage'
import './App.css' import './App.css'
export default function App() { export default function App() {
const basePath = "LACONIC_HOSTED_CONFIG_web_path"
return ( return (
<Router> <Router>
<div> <div>
<Switch> <Switch>
<Route exact path="/newuser/" component={ RegisterPage } /> <Route exact path={basePath} component={ RegisterPage } />
{/*<Route path="/login" component={ LoginPage } />*/} <Route path={basePath + "/register"} component={ RegisterPage } />
<Route path="/newuser/register" component={ RegisterPage } />
{/*<Route path="/forget-password" component={ ForgetPasswordPage } />*/}
{/*<Route path="/home" component={ HomePage } />*/}
</Switch> </Switch>
<Footer /> <Footer />
</div> </div>

View File

@ -9,9 +9,10 @@ export default function SignUpPage() {
const [message, setMessage] = useState(""); const [message, setMessage] = useState("");
let handleSubmit = async (e) => { let handleSubmit = async (e) => {
const apiBase = "LACONIC_HOSTED_CONFIG_api_url";
e.preventDefault(); e.preventDefault();
try { try {
let res = await fetch("/register", { let res = await fetch(`${apiBase}/register`, {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -38,12 +39,12 @@ export default function SignUpPage() {
{/*<h2>Join us</h2>*/} {/*<h2>Join us</h2>*/}
{/*<h5>Create your personal account</h5>*/} {/*<h5>Create your personal account</h5>*/}
<form onSubmit={handleSubmit} action=""> <form onSubmit={handleSubmit} action="">
<p> {/*<p>*/}
<label>Username</label><br/> {/* <label>Username</label><br/>*/}
<input type="text" name="username" {/* <input type="text" name="username"*/}
onChange={(e) => setUsername(e.target.value)} {/* onChange={(e) => setUsername(e.target.value)}*/}
required /> {/* required />*/}
</p> {/*</p>*/}
<p> <p>
<label>Email address</label><br/> <label>Email address</label><br/>
<input type="email" name="email" <input type="email" name="email"