Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Mason committed Mar 23, 2020
1 parent 2d61611 commit 93dd87f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
8 changes: 5 additions & 3 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@ RUN yarn --non-interactive build-web

# production environment
FROM nginx:1.16.0-alpine
WORKDIR /usr/share/nginx/html
RUN apk update && apk upgrade && apk add bash
COPY --from=build /app/web/dist /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY web/nginx.conf /etc/nginx/conf.d/default.conf
COPY web/gzip.conf /etc/nginx/conf.d/gzip.conf
# RUN echo "http://admin:admin@localhost:5984" > /usr/share/nginx/html/env-config.js
EXPOSE 80

COPY ./web/env.sh .
COPY web/env.sh .
COPY .env .

RUN ls -la
# Add bash

# Make our shell script executable
RUN chmod +x env.sh
RUN which sh

# Start Nginx server
CMD ["/bin/sh", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]
Expand Down
2 changes: 0 additions & 2 deletions app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
}
})();
</script>
<script src="%PUBLIC_URL%/env-config.js"></script>
<script src="/env-config.js"></script>
</head>
<body>
<div id="root"></div>
Expand Down
11 changes: 5 additions & 6 deletions app/containers/HomePage/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ export function setMainMenuVisibility(visible: boolean) {
export function saveStoreConfig(key: string, vb: any) {
return (dispatch: Dispatch, getState: GetState) => {
console.log("savings", key, vb, store)
// dispatch({
// type: SET_CONFIG,
// id: key,
// attributes: vb
// })
store.set(key, vb)
dispatch({
type: SET_CONFIG,
id: key,
attributes: vb
})

};
}
2 changes: 2 additions & 0 deletions app/reducers/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function configReducer(state = initialState, action: Action<string>) {
case SET_CONFIG:
const newState = {...state, [action.id]: action.attributes}
// saveState(newState)
store.set(key, vb)

return newState
// case '@@redux-pouchdb/SET_OBJECT_REDUCER':
// return action.state
Expand Down
12 changes: 6 additions & 6 deletions app/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

import isElectron from 'is-electron';
import PouchDB from 'pouchdb';
const Store = require('electron-store');

const store = new Store('config');

const config = require('config');

Expand All @@ -12,15 +9,19 @@ const config = require('config');


if (!isElectron()) {
console.log("Web deployment. Using backend URL: ", config)
console.log("Web deployment. window._env_: ", window._env_)
console.log("Web deployment. Webpack compiled config: ", config)
console.log("Web deployment. .env file config: ", window._env_)

if (window._env_.DB_CONNECTION) {
config.db = window._env_.DB_CONNECTION
} else {
console.error("App is not running in electron. DB_CONNECTION environment variable containing the full database connection string must be defined on docker container")
}
} else {
const Store = require('electron-store');

const store = new Store('config');

const c = store.get('db')
// const configDB = new PouchDB('data/config');
// const con = configDB.get("_local/config")
Expand All @@ -33,4 +34,3 @@ if (!isElectron()) {
}
}
export default config
export {store}
4 changes: 1 addition & 3 deletions configs/webpack.config.web.dev.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ const devConfig = merge.smart(baseConfig, {
node: {
fs: 'empty',
'graceful-fs': 'empty',
'conf': 'empty',
'write-file-atomic': 'empty',
'fs-extra': 'empty',
'fs-realpath': 'empty',
'electron-updater': 'empty',
'electron-log': 'empty',
'electron-devtools-installer': 'empty',
'path-exists': 'empty',
glob: 'empty',
child_process: 'empty',
module: 'empty',
Expand Down Expand Up @@ -218,7 +216,7 @@ const devConfig = merge.smart(baseConfig, {

new HtmlWebpackPlugin({
hash: true,
template: './web/index.template.html',
template: './web/index.web.html',
filename: 'index.html' // relative to root of the application
})
],
Expand Down
2 changes: 1 addition & 1 deletion configs/webpack.config.web.prod.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const productionConfig = merge.smart(baseConfig, {

new HtmlWebpackPlugin({
hash: true,
template: './web/index.template.html',
template: './web/index.web.html',
filename: 'index.html' // relative to root of the application
})
],
Expand Down
1 change: 1 addition & 0 deletions docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build -t danobot/notorious:latest -f Dockerfile.prod .
1 change: 1 addition & 0 deletions web/index.template.html → web/index.web.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>Notorious</title>
<script src="/env-config.js"></script>
</head>
<body>
<div id="root"></div>
Expand Down

0 comments on commit 93dd87f

Please sign in to comment.