Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:16.13
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install
RUN npm run build
EXPOSE 3000
ENTRYPOINT ["node", "./server/server.js"]
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div id="root" style="height:100%"></div>

<!-- script for webpack and webpack-dev-server challenge -->
<!-- <script src="dist/bundle.js"></script> -->
<script src="dist/bundle.js"></script>

<!-- uncomment below and comment out the tag above for gulp/browserify challenge -->
<!-- <script src="build/browserify-bundle.js"></script> -->
Expand Down
11 changes: 11 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const express = require('express');
const session = require("express-session");
const passport = require('passport');
const path = require('path');

require('dotenv').config();
require('./auth');

Expand Down Expand Up @@ -83,6 +85,15 @@ app.get('/logout', ( req,res)=> {
// Implementation is flexibile, can change if needed
app.use('/api', apiRouter);

// statically serve everything in the build folder on the route '/build'
if (process.env.NODE_ENV === 'production') {
app.use('/dist', express.static(path.join(__dirname, '../dist')));
// serve index.html on the route '/'
app.get('/', (req, res) => {
return res.status(200).sendFile(path.join(__dirname, '../index.html'));
});
}

// Catch-all error handler
app.use('*', (req, res) => {
res.sendStatus(404);
Expand Down
11 changes: 6 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './client/index.tsx',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
path: path.join(__dirname, 'dist'),
clean: true,
publicPath: '/',
},
devtool: 'eval-source-map', //comment it out when doing the production run
// devtool: 'eval-source-map', //comment it out when doing the production run
devServer: {
host: 'localhost',
port: 8080,
Expand All @@ -28,15 +29,15 @@ module.exports = {
},
'/protected': {
target: 'http://localhost:3000',
secure: false
secure: false,
},
'/logout': {
target: 'http://localhost:3000',
secure: false
secure: false,
},
'/google/**': {
target: 'http://localhost:3000',
secure: false
secure: false,
},
},
static: {
Expand Down